:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --border: #e4e8f0;
  --text: #1b2436;
  --muted: #6b7891;
  --brand: #2f6bff;
  --brand-dark: #1b4fd8;
  --danger: #ef4444;
  --ok: #10b981;
  --warn: #f59e0b;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(27, 36, 54, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: 14px; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 60px;
  background: linear-gradient(90deg, #1e3a8a, #2f6bff);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 2px 12px rgba(30, 58, 138, 0.25);
}
.topbar .logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: rgba(255,255,255,0.18);
  display: grid; place-items: center; font-size: 17px;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: .5px; }
.topbar .spacer { flex: 1; }
.conn {
  font-size: 12.5px; padding: 5px 12px; border-radius: 999px;
  background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.25);
}
.conn.dot::before {
  content: ""; display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; background: #4ade80; margin-right: 7px; vertical-align: 1px;
}
.conn.bad::before { background: #fca5a5; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar {
  width: 212px; flex: none; background: var(--panel);
  border-right: 1px solid var(--border); padding: 18px 12px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border: none; background: transparent;
  border-radius: 10px; color: var(--muted); font-size: 14px; text-align: left;
}
.nav-item:hover { background: #f1f4fa; color: var(--text); }
.nav-item.active { background: #eaf0ff; color: var(--brand-dark); font-weight: 600; }
.nav-item .badge {
  margin-left: auto; background: var(--brand); color: #fff;
  font-size: 11px; padding: 1px 7px; border-radius: 999px;
}
.content { flex: 1; padding: 22px 26px 50px; min-width: 0; }

/* ---------- 通用组件 ---------- */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }

.btn {
  border: none; border-radius: 9px; padding: 8px 16px;
  background: var(--brand); color: #fff; font-size: 13.5px; font-weight: 500;
  transition: .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: #eef2fb; color: var(--text); }
.btn.ghost:hover { background: #e0e7f6; }
.btn.outline { background: #fff; color: var(--brand); border: 1px solid #c9d7ff; }
.btn.outline:hover { background: #f2f6ff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field input, .field select {
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px;
  background: #fbfcfe; outline: none; transition: .15s;
}
.field input:focus, .field select:focus { border-color: var(--brand); background: #fff; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.checkbox input { width: 15px; height: 15px; accent-color: var(--brand); }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat .bar { height: 5px; border-radius: 3px; margin-top: 10px; background: #eef1f7; overflow: hidden; }
.stat .bar span { display: block; height: 100%; border-radius: 3px; }

/* ---------- 筛选 ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input, .toolbar select {
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px;
  background: #fff; min-width: 140px;
}

/* ---------- 运单卡片 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.shipment { padding: 16px 18px; cursor: pointer; transition: .18s; }
.shipment:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(27,36,54,.12); }
.shipment .row1 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.shipment .no { font-weight: 600; font-size: 15px; letter-spacing: .3px; }
.shipment .route { margin: 12px 0 14px; color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.shipment .meta-line { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }

.tag {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; font-weight: 600; white-space: nowrap;
}
.node-hint {
  font-size: 12px; color: var(--brand-dark); background: #eef3ff;
  padding: 6px 10px; border-radius: 8px; margin-top: 12px;
}

/* ---------- 抽屉 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
  opacity: 0; pointer-events: none; transition: .2s; z-index: 40;
}
.mask.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100%);
  background: var(--panel); z-index: 50; transform: translateX(100%);
  transition: transform .25s ease; display: flex; flex-direction: column;
  box-shadow: -8px 0 30px rgba(17,24,39,.18);
}
.drawer.show { transform: translateX(0); }
.drawer-head {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px;
}
.drawer-head h3 { margin: 0 0 6px; font-size: 17px; }
.drawer-body { padding: 18px 22px 40px; overflow-y: auto; flex: 1; }
.close-x { border: none; background: #f1f4fa; width: 30px; height: 30px; border-radius: 8px; font-size: 16px; }

.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 14px 0 20px; }
.info-grid div { background: #f7f9fd; border-radius: 10px; padding: 10px 12px; }
.info-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }

.section-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 18px 0 10px; letter-spacing: .5px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 时间轴 ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid #e6ebf5; }
.timeline li { position: relative; padding: 0 0 18px 16px; }
.timeline li::before {
  content: ""; position: absolute; left: -25px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--brand);
  border: 2px solid #fff; box-shadow: 0 0 0 2px #dbe4fb;
}
.timeline .time { font-size: 12px; color: var(--muted); }
.timeline .name { font-weight: 600; font-size: 13.5px; margin: 2px 0; }
.timeline .code { font-size: 11.5px; color: var(--muted); font-family: Consolas, monospace; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
.table th { background: #f7f9fd; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.table tr:last-child td { border-bottom: none; }
.table td.content-cell { max-width: 460px; color: #374151; }

/* ---------- 模态 ---------- */
.modal-wrap {
  position: fixed; inset: 0; z-index: 60; display: none;
  align-items: center; justify-content: center; background: rgba(17,24,39,.45);
}
.modal-wrap.show { display: flex; }
.modal {
  background: var(--panel); border-radius: 16px; width: min(430px, 92vw);
  padding: 22px 24px; box-shadow: 0 20px 50px rgba(0,0,0,.25);
  max-height: 88vh; display: flex; flex-direction: column;
}
.modal.wide { width: min(700px, 94vw); }
.modal-scroll { overflow-y: auto; padding-right: 6px; margin-right: -6px; }
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.group-title {
  font-size: 12px; font-weight: 600; color: var(--brand-dark);
  background: #eef3ff; padding: 6px 10px; border-radius: 7px; margin: 4px 0 12px;
}
.inline-checks { display: flex; gap: 18px; margin: 4px 0 4px; }
.hidden-row { display: none !important; }

/* ---------- 运单卡片（国际货运） ---------- */
.progress { height: 6px; border-radius: 4px; background: #eef1f7; overflow: hidden; margin: 12px 0 10px; }
.progress span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #2f6bff, #22d3ee); transition: width .3s; }
.progress.exc span { background: linear-gradient(90deg, #f97316, #ef4444); }
.route-line { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); margin-bottom: 8px; }
.route-line .arrow { color: var(--brand); }
.tagpair { display: flex; gap: 6px; }
.mini-tag { font-size: 11px; padding: 3px 8px; border-radius: 6px; font-weight: 600; background: #eef1f6; color: #475569; }
.mini-tag.sea { background: #e0f2fe; color: #0369a1; }
.mini-tag.air { background: #f3e8ff; color: #7e22ce; }
.mini-tag.export { background: #dcfce7; color: #047857; }
.mini-tag.import { background: #fff7ed; color: #c2410c; }

/* 关键时效信息 */
.time-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0 18px; }
.time-grid div { background: #f7f9fd; border-radius: 10px; padding: 9px 12px; border-left: 3px solid var(--brand); }
.time-grid div.danger { border-left-color: var(--danger); background: #fff5f5; }
.time-grid div.warn { border-left-color: var(--warn); background: #fffbeb; }
.time-grid span { display: block; color: var(--muted); font-size: 11.5px; margin-bottom: 2px; }
.time-grid strong { font-size: 13px; font-weight: 600; }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast {
  background: #fff; border-left: 4px solid var(--ok); border-radius: 10px;
  padding: 11px 16px; box-shadow: var(--shadow); font-size: 13px; min-width: 220px;
  max-width: 420px; white-space: pre-line; line-height: 1.6;
  animation: slide-in .22s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--brand); }
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } }

.empty { text-align: center; color: var(--muted); padding: 44px 0; font-size: 13.5px; }
.spinner {
  width: 26px; height: 26px; border: 3px solid #dbe4fb; border-top-color: var(--brand);
  border-radius: 50%; margin: 40px auto; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 登录页 ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 2000; display: none;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eaf0ff 0%, #f7f9fd 55%, #e6f7ff 100%);
}
.login-screen.show { display: flex; }
.login-card {
  width: min(380px, 92vw); background: var(--panel); border-radius: 18px;
  padding: 30px 28px 26px; box-shadow: 0 20px 50px rgba(27, 36, 54, 0.12);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .login-logo {
  width: 46px; height: 46px; border-radius: 12px; background: #eaf0ff;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.login-brand h2 { margin: 0; font-size: 17px; }
.login-brand p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 4px; }
.login-err {
  padding: 9px 12px; border-radius: 8px; background: #fee2e2; color: #b91c1c;
  font-size: 12.5px; margin-bottom: 12px; display: none;
}
.login-err.show { display: block; }
.login-tip {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted); line-height: 1.7; text-align: center;
}
.login-tip code { background: #f1f4f9; padding: 1px 5px; border-radius: 4px; }

@media (max-width: 860px) {
  .sidebar { width: 66px; padding: 14px 8px; }
  .nav-item span.label { display: none; }
  .nav-item { justify-content: center; padding: 11px; }
  .nav-item .badge { display: none; }
  .content { padding: 16px; }
  .info-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
