/* ==========================================================================
   小宇快递助手 · 设计系统（移动优先，桌面端增强）
   ========================================================================== */

:root {
  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --primary-soft: #eef2ff;
  --violet: #7c3aed;
  --accent: #f97316;
  --accent-soft: #fff7ed;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --ink: #181a2a;
  --ink-2: #3f4356;
  --muted: #8a90a6;
  --line: #eceef4;
  --bg: #f5f6fb;
  --surface: #ffffff;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --shadow-sm: 0 1px 2px rgba(24, 26, 42, 0.04), 0 1px 6px rgba(24, 26, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(24, 26, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(79, 70, 229, 0.16);
  --grad-brand: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --grad-accent: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 100% -10%, #eef2ff 0%, transparent 60%),
    radial-gradient(900px 400px at -10% 0%, #fdf4ff 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }

/* ---------- 顶栏：全宽，独立于内容容器 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  /* 窄屏兜底：管理端导航有 6 项，手机上横着放不下。
     flex-wrap 让它折到第二行，而不是把最右边的「公告管理」「退出」截掉/挤出屏幕。
     桌面端宽度够，这行不生效，外观不变。 */
  flex-wrap: wrap;
  row-gap: 8px;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.08rem; }
.brand-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--grad-brand); color: #fff; font-size: 1.15rem;
  box-shadow: var(--shadow-md); flex-shrink: 0;
}
.topbar-user { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; row-gap: 8px; }
.topbar-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; row-gap: 6px; }
/* 折行后整组右对齐，视觉上仍贴着顶栏右侧，不会跟着品牌名左漂 */
.topbar-nav, .topbar-user { margin-left: auto; }
/* 导航项内部不许拆行：「公告管理」被劈成「公告\n管理」比截断还难读 */
.nav-link { white-space: nowrap; }
.topbar .btn { white-space: nowrap; }

.code-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-strong);
  font-size: 0.88rem; font-weight: 600;
}
.code-pill strong {
  font-size: 1.05rem; letter-spacing: 0.5px;
  background: var(--grad-brand);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-link {
  padding: 8px 16px; border-radius: 999px;
  color: var(--ink-2); font-size: 0.9rem; font-weight: 600;
  transition: background 0.18s, color 0.18s;
}
.nav-link:hover { background: var(--primary-soft); color: var(--primary); }
.nav-link.active { background: var(--grad-brand); color: #fff; box-shadow: var(--shadow-md); }

/* ---------- 内容区容器（仅在顶栏下方页面使用） ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 20px; }
/* 管理端表格页（快递记录/客户名录/操作日志）列多，1100px 装不下 8 列会出横向滚动条，
   把「删除」按钮挤到屏幕外。这几个页面单独放宽，保证桌面端不左右滑动也能看全。
   用修饰类而不是直接改 .container：客户端页面（录入表单/历史）窄一点更好读。 */
.container--wide { max-width: 1440px; }

/* ---------- 认证页（登录/注册/错误）全屏居中 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border-radius: var(--r-xl);
  overflow: hidden; box-shadow: var(--shadow-lg);
}
.auth-hero {
  background: var(--grad-brand); color: #fff;
  padding: 34px 28px 28px; text-align: center;
  position: relative; overflow: hidden;
}
.auth-hero::after {
  content: ""; position: absolute; inset: -40%;
  background: radial-gradient(circle at 70% 20%, rgba(255,255,255,0.22), transparent 55%);
  pointer-events: none;
}
.auth-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 62px; height: 62px; border-radius: 18px;
  background: rgba(255,255,255,0.18); font-size: 2rem; margin-bottom: 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}
.auth-hero h1 { font-size: 1.4rem; font-weight: 800; letter-spacing: 0.5px; }
.auth-hero p { font-size: 0.9rem; opacity: 0.9; margin-top: 4px; }
.auth-body { padding: 26px 28px 30px; }
.auth-footer { text-align: center; padding-top: 6px; font-size: 0.9rem; color: var(--muted); }
.auth-footer a { font-weight: 600; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 22px;
  box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.card:last-child { margin-bottom: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card-title { display: flex; align-items: center; gap: 12px; font-size: 1.15rem; font-weight: 800; }
.card-title .sub { display: block; font-size: 0.8rem; font-weight: 500; color: var(--muted); }

.icon-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px; font-size: 1.25rem; flex-shrink: 0;
}
.icon-badge--indigo { background: var(--primary-soft); }
.icon-badge--orange { background: var(--accent-soft); }
.icon-badge--green { background: var(--success-soft); }

/* ---------- 统计卡片 ---------- */
.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat-num { font-size: 2rem; font-weight: 800; line-height: 1; letter-spacing: -0.5px; }
.stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
.stat-icon { position: absolute; right: 14px; top: 14px; font-size: 1.6rem; opacity: 0.9; }
.stat-card--brand .stat-num { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-card--accent .stat-num { color: var(--accent); }

/* ---------- 表单 ---------- */
.form-field { margin-bottom: 16px; }
.form-field > label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.form-field .req { color: var(--danger); }

.input, .select {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1.5px solid var(--line); border-radius: var(--r-sm);
  font-size: 1rem; font-family: inherit; color: var(--ink); background: #fbfbfe;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  -webkit-appearance: none; appearance: none;
}
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238a90a6' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 4 3.5-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
.input:focus, .select:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12); }
.input::placeholder { color: #b6bbce; }

.hint { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 6px; }
.hint--accent { color: var(--accent); font-weight: 500; }

.form-msg { margin-top: 14px; font-size: 0.9rem; font-weight: 600; min-height: 1.4em; }
.form-msg.success { color: var(--success); }
.form-msg.error { color: var(--danger); }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 14px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 20px; border: 1.5px solid transparent;
  border-radius: var(--r-sm); font-size: 0.95rem; font-weight: 700;
  font-family: inherit; cursor: pointer; text-align: center;
  transition: transform 0.12s, box-shadow 0.18s, background 0.18s, opacity 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad-brand); color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4); }
.btn-accent { background: var(--grad-accent); color: #fff; box-shadow: 0 4px 14px rgba(249, 115, 22, 0.3); }
.btn-outline { background: #fff; color: var(--primary); border-color: #cfd3f2; }
.btn-outline:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn-ghost { background: #f1f2f7; color: var(--ink-2); }
.btn-ghost:hover { background: #e8e9f1; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 0.85rem; border-radius: 9px; }
.btn-block { width: 100%; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; }
/* min-width 给内容列留出基本空间：窄屏就横向滚动，别把「操作」列的按钮挤没 */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 640px; }
thead th {
  text-align: left; padding: 13px 16px; font-size: 0.78rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px;
  background: #f8f9fc; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; color: var(--ink-2); }
/* 长内容列（取件码/备注）：默认 nowrap 会让 40 多字的取件码把整张表撑出横向滚动条，
   这里改成可换行。用 overflow-wrap:anywhere 而不是 word-break:break-all —— 前者只在
   「整个词放不下」时才断，中文短词（如「圆通」）不会被从中间劈开，但它同时会参与
   浏览器的最小列宽计算，长串列才收缩得下来（break-word 不参与，列会被长串撑住不放）。 */
td.cell-wrap { white-space: normal; overflow-wrap: anywhere; line-height: 1.45; min-width: 140px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: #fafbff; }
.cell-strong { color: var(--ink); font-weight: 700; }
/* 操作列按钮保持居中，行高不同也不跳动 */
.cell-actions { white-space: nowrap; }
.cell-actions .btn { margin-right: 4px; }
.cell-actions .btn:last-child { margin-right: 0; }

.company-badge {
  display: inline-flex; align-items: center; padding: 4px 12px;
  border-radius: 999px; font-size: 0.82rem; font-weight: 700; white-space: nowrap;
}
.company-badge[data-company="圆通"] { background: #fef3c7; color: #b45309; }
.company-badge[data-company="顺丰"] { background: #fee2e2; color: #b91c1c; }
.company-badge[data-company="中通"] { background: #dbeafe; color: #1d4ed8; }
.company-badge[data-company="申通"] { background: #d1fae5; color: #047857; }
.company-badge[data-company="韵达"] { background: #ffedd5; color: #c2410c; }
.company-badge[data-company="极兔"] { background: #ffe4e6; color: #be123c; }
.company-badge[data-company="邮政"] { background: #dcfce7; color: #15803d; }
.company-badge[data-company="京东"] { background: #fce7f3; color: #be185d; }

.pickup-code {
  font-family: "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
  font-weight: 700; color: var(--primary-strong); background: var(--primary-soft);
  padding: 2px 8px; border-radius: 6px; letter-spacing: 0.5px;
}

/* ---------- 地址列表 ---------- */
.addr-list { list-style: none; margin-bottom: 14px; }
.addr-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 15px;
  border: 1.5px solid var(--line); border-radius: var(--r-md); margin-bottom: 10px;
  background: #fbfbfe; transition: border-color 0.18s, background 0.18s;
}
.addr-item.is-default { border-color: var(--primary); background: var(--primary-soft); }
.addr-code { font-weight: 800; font-size: 1.05rem; }
.addr-actions { margin-left: auto; display: flex; gap: 6px; }
.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; background: var(--grad-brand); color: #fff; }

/* ---------- 搜索栏 ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar .input { flex: 1; height: 46px; }

/* ---------- 提示 ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 13px 16px;
  border-radius: var(--r-md); margin-bottom: 16px; font-size: 0.92rem; line-height: 1.5;
}
.alert-error { background: var(--danger-soft); color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: var(--success-soft); color: #166534; border: 1px solid #bbf7d0; }

/* ---------- 模态框 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(24, 26, 42, 0.5);
  backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px; animation: fadeIn 0.2s ease;
}
.modal.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: var(--r-lg); padding: 26px;
  width: 100%; max-width: 430px; box-shadow: var(--shadow-lg); animation: slideUp 0.22s ease;
}
.modal-box h3 { font-size: 1.1rem; font-weight: 800; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

/* 确认弹窗：字段对照，方便一眼核对驿站/取件码 */
.confirm-list { display: grid; gap: 8px; margin: 4px 0 18px; }
.confirm-list > div {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 10px 12px; background: #f8f9fc; border-radius: 10px;
}
.confirm-list dt { color: var(--muted); font-size: 0.82rem; font-weight: 600; flex-shrink: 0; }
.confirm-list dd { font-weight: 700; text-align: right; word-break: break-all; color: var(--ink); }

/* 修改弹窗顶部的「改动前后」对照：只列出真正被改动的字段，一眼看清改了什么 */
.diff-list { list-style: none; margin: 0 0 16px; display: grid; gap: 6px; }
.diff-list li {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 10px;
  padding: 9px 12px; font-size: 0.86rem;
}
.diff-field { color: #b45309; font-weight: 700; flex-shrink: 0; }
.diff-from { color: #9a3412; text-decoration: line-through; word-break: break-all; }
.diff-arrow { color: #b45309; }
.diff-to { color: #166534; font-weight: 700; word-break: break-all; }
.diff-list .diff-empty { background: #f8f9fc; border-color: var(--line); color: var(--muted); }

/* 刚插入的历史行闪一下，让用户立刻意识到「已经记上了」 */
@keyframes rowFlash {
  from { background: #fff7ed; }
  to { background: transparent; }
}
tr.just-added { animation: rowFlash 1.6s ease; }

/* 修改/删除后原地更新那一行，同样闪一下反馈「这条改动生效了」 */
tr.just-updated { animation: rowFlash 1.6s ease; }

.hidden { display: none !important; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ---------- 空状态 ---------- */
.empty-state { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 68px; height: 68px; border-radius: 20px; background: #f1f2f7;
  font-size: 2rem; margin-bottom: 14px;
}

/* ---------- 工具 ---------- */
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.inline { display: inline; }

/* ---------- 日志页 ---------- */
.log-badge {
  display: inline-flex; align-items: center; padding: 2px 10px;
  border-radius: 999px; font-size: 0.78rem; font-weight: 700; white-space: nowrap;
}
.log-badge--admin { background: #fee2e2; color: #b91c1c; }
.log-badge--client { background: #dbeafe; color: #1d4ed8; }
.log-badge--system { background: #f1f2f7; color: var(--ink-2); }
.log-detail {
  max-width: 320px; white-space: normal; word-break: break-all; line-height: 1.4;
  font-size: 0.82rem;
}
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--line);
}
/* 分页按钮组：页码之间留小间距，窄屏自动换行不撑破 */
.pager-pages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager-pages .btn { padding: 0 12px; }
.pager-num { min-width: 36px; }
.pager-ellipsis { color: var(--muted); padding: 0 2px; letter-spacing: 1px; }
/* 首尾页时「上一页/下一页」置灰但仍占位，避免按钮整体左右跳动 */
.btn.is-disabled { opacity: 0.45; cursor: default; pointer-events: none; }

/* ---------- 公告 ---------- */
.announce-banner {
  display: flex; align-items: flex-start; gap: 10px;
  max-width: 1100px; margin: 0 auto; padding: 12px 20px;
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  border-bottom: 1px solid #fde68a;
  color: #92400e; font-size: 0.92rem; line-height: 1.5;
}
.announce-icon { flex-shrink: 0; }
.announce-text { word-break: break-all; white-space: pre-wrap; }

.bell-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: none; border-radius: 12px;
  background: #f1f2f7; cursor: pointer; transition: background 0.18s;
}
.bell-btn:hover { background: #e8e9f1; }
.bell-icon { font-size: 1.2rem; }
.bell-dot {
  position: absolute; top: 8px; right: 9px; width: 9px; height: 9px;
  background: var(--danger); border-radius: 50%;
  border: 2px solid #fff;
}

.announce-list { list-style: none; max-height: 60vh; overflow-y: auto; }
.announce-item {
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.announce-item:last-child { border-bottom: none; }
.announce-item-text { color: var(--ink); font-size: 0.95rem; line-height: 1.6; word-break: break-all; white-space: pre-wrap; }
.announce-item-time { color: var(--muted); font-size: 0.78rem; margin-top: 6px; }

/* ---------- 布局 ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.narrow { max-width: 480px; margin: 0 auto; }

/* ---------- 动效 ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- 桌面端增强 ---------- */
@media (min-width: 760px) {
  .container { padding: 24px; }
  .topbar { padding: 14px 28px; }
  .grid { grid-template-columns: 1.05fr 0.95fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .form-field--full { grid-column: 1 / -1; }
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

/* ---------- 窄屏（手机）：顶栏紧凑化 ---------- */
@media (max-width: 759px) {
  /* 手机上「· 管理后台」是纯装饰，白占半行，窄屏隐藏 */
  .topbar-brand .small { display: none; }
  .topbar { padding: 10px 14px; }
  .topbar-brand { font-size: 1rem; }
  /* 导航项左内边距收窄，6 项才更容易挤进一行 */
  .nav-link, .topbar .btn { padding: 6px 11px; }
  /* 客户端顶栏是 编号徽章+铃铛+修改密码+退出 四项，360px 下原间距总和比
     可用宽度只多几像素，会被硬拆成两行、最后一个元素孤零零落到左边。
     这里把间距和徽章内边距各收一点，正好省出一行的余量。 */
  .topbar-user { gap: 6px; }
  .code-pill { padding: 6px 10px; }
  /* 320px 这类极窄屏（iPhone SE 一代）四项仍放不下，会折成两行。
     折行时按行右对齐，第二行贴着右边缘，看起来是刻意换行而不是排版错位。 */
  .topbar-nav, .topbar-user { justify-content: flex-end; }
}
