/* ==========================================================================
   快递管家 · 移动优先样式
   断点：默认手机单列 / 640 平板 / 900 桌面
   ========================================================================== */

:root {
  --brand: #2F5BEA;
  --brand-deep: #1C3AA8;
  --brand-soft: #EEF3FF;
  --bg: #F4F6FB;
  --card: #FFFFFF;
  --line: #E6EAF2;
  --text: #1B2437;
  --text-2: #54607A;
  --text-3: #8A96AC;
  --danger: #D93A3A;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(28, 48, 100, .05), 0 10px 30px rgba(28, 48, 100, .035);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(72px + var(--safe-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

/* ---------- 顶栏 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-icon { width: 36px; height: 36px; border-radius: 9px; flex: none; }
.brand-text h1 { font-size: 17px; font-weight: 700; letter-spacing: .2px; }
.brand-text p { font-size: 11px; color: var(--text-3); letter-spacing: .4px; }
.icon-btn {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--text-2);
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:active { background: var(--brand-soft); }

/* ---------- 视图 ---------- */
main { max-width: 720px; margin: 0 auto; padding: 14px 14px 24px; }
.view { animation: fade .18s ease; }
@keyframes fade { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.notice {
  background: #FFF9E9; border: 1px solid #F5E4B8; border-radius: 14px;
  padding: 12px 14px; margin-bottom: 12px; color: #6B5424; font-size: 12.5px; line-height: 1.65;
}
.notice-title { font-weight: 700; font-size: 13px; margin-bottom: 3px; }
.notice p { color: #7A6437; }
.notice.slim { background: var(--brand-soft); border-color: #D9E4FF; color: #2B4480; }
.notice b { font-weight: 700; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card-title {
  font-size: 14px; font-weight: 700; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.card-title.with-side { justify-content: space-between; }
.step {
  width: 20px; height: 20px; border-radius: 7px; background: var(--brand); color: #fff;
  font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; flex: none;
}

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--text-2);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip.active .dot { box-shadow: 0 0 0 2px rgba(255,255,255,.55); }
.chips.small .chip { padding: 6px 12px; min-height: 32px; font-size: 12px; }

/* ---------- 表单 ---------- */
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin: 12px 0 6px; }
.field-hint { font-size: 11.5px; color: var(--text-3); line-height: 1.6; margin-top: 8px; }
.input-row { display: flex; gap: 7px; align-items: stretch; }
input[type="text"], input[type="search"], select, textarea {
  width: 100%; border: 1px solid var(--line); background: #FBFCFE; border-radius: 11px;
  padding: 11px 12px; font-size: 16px; outline: none; min-height: 44px;
}
input[type="text"]:focus, input[type="search"]:focus, select:focus, textarea:focus {
  border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(47,91,234,.10);
}
input::placeholder, textarea::placeholder { color: #A8B2C4; }
.input-row input { flex: 1; min-width: 0; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%238A96AC' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
textarea { resize: vertical; line-height: 1.6; }

.mini-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 0 12px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; flex: none;
}
.mini-btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.mini-btn:active { background: var(--brand-soft); }

.btn-primary {
  width: 100%; min-height: 50px; border: 0; border-radius: 12px;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  box-shadow: 0 6px 16px rgba(47, 91, 234, .22);
}
.btn-primary svg { width: 17px; height: 17px; }
.btn-primary:active { background: var(--brand-deep); }
.btn-row { display: flex; gap: 8px; margin-top: 9px; }
.btn-row.three > * { flex: 1; min-width: 0; }
.btn-ghost {
  min-height: 40px; border: 1px solid var(--line); background: #fff; color: var(--text-2);
  border-radius: 10px; font-size: 12.5px; padding: 0 8px; white-space: nowrap;
}
.btn-ghost:active { background: var(--brand-soft); }
.btn-danger { min-height: 40px; border: 0; border-radius: 10px; background: var(--danger); color: #fff; font-weight: 600; font-size: 13px; flex: 1; }
.btn-danger:disabled { background: #E7C9C9; cursor: not-allowed; }
.link-btn { border: 0; background: none; color: var(--brand); font-size: 12px; padding: 4px 0; }

/* ---------- 概览数字 ---------- */
.metric-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 12px; }
.metric {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 8px; text-align: center; box-shadow: var(--shadow);
}
.metric span { display: block; font-size: 23px; font-weight: 750; color: var(--brand); line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric small { font-size: 11px; color: var(--text-3); }

/* ---------- 最近记录 ---------- */
.recent-list { display: flex; flex-direction: column; gap: 2px; }
.recent-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 2px;
  border-bottom: 1px solid #F1F4F9; min-width: 0;
}
.recent-item:last-child { border-bottom: 0; }
.recent-main { flex: 1; min-width: 0; }
.recent-num { font-size: 13.5px; font-weight: 650; letter-spacing: .4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.recent-sub { font-size: 11px; color: var(--text-3); }
.empty { color: var(--text-3); font-size: 12.5px; text-align: center; padding: 18px 8px; }

/* ---------- 包裹页 ---------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.toolbar input { flex: 1; min-width: 0; }
.filter-label { font-size: 11px; font-weight: 700; color: var(--text-3); letter-spacing: .5px; margin: 10px 0 7px; }
.list-count { font-size: 12px; color: var(--text-3); margin: 14px 2px 8px; }
.parcel-list { display: flex; flex-direction: column; gap: 10px; }

.parcel-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; box-shadow: var(--shadow); }
.pc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pc-number { font-size: 16px; font-weight: 700; letter-spacing: .6px; word-break: break-all; font-variant-numeric: tabular-nums; }
.pc-copy { border: 0; background: var(--brand-soft); color: var(--brand); border-radius: 8px; font-size: 11.5px; padding: 5px 9px; flex: none; }
.pc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0 0; }
.tag { font-size: 11px; padding: 3px 9px; border-radius: 7px; background: #F2F5FA; color: var(--text-2); }
.tag.platform { color: #fff; font-weight: 600; }
.tag.status-tag { font-weight: 600; }
.pc-note { font-size: 12px; color: var(--text-2); background: #F7F9FD; border-radius: 9px; padding: 8px 10px; margin-top: 9px; white-space: pre-wrap; word-break: break-word; }
.pc-meta { font-size: 11px; color: var(--text-3); margin-top: 9px; }
.pc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; padding-top: 10px; border-top: 1px solid #F1F4F9; align-items: center; }
.pc-actions button, .pc-actions select { font-size: 11.5px; min-height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text-2); padding: 0 9px; }
.pc-actions select { width: auto; min-width: 96px; font-size: 11.5px; padding: 0 26px 0 9px; background-position: right 8px center; }
.pc-actions .go { background: var(--brand-soft); border-color: #D9E4FF; color: var(--brand); font-weight: 600; }
.pc-actions .del { color: var(--danger); margin-left: auto; }

/* ---------- 统计 ---------- */
.chart-card { padding: 14px 12px 10px; }
.chart-card .card-title { padding: 0 4px; margin-bottom: 4px; }
.chart { width: 100%; height: 230px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(255,255,255,.95); border-top: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding-bottom: var(--safe-bottom);
}
.tab {
  border: 0; background: none; padding: 8px 0 7px; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px;
}
.tab svg { width: 21px; height: 21px; }
.tab.active { color: var(--brand); font-weight: 700; }

/* ---------- 弹层 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .42); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: #fff; border-radius: 20px 20px 0 0;
  max-height: 86vh; display: flex; flex-direction: column;
  animation: sheetUp .22s cubic-bezier(.2,.8,.2,1);
  padding-bottom: var(--safe-bottom);
}
.sheet.tall { max-height: 92vh; }
@keyframes sheetUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px 11px; border-bottom: 1px solid var(--line); flex: none;
}
.sheet-head h2 { font-size: 16px; font-weight: 700; }
.sheet-close { border: 0; background: #F2F5FA; width: 30px; height: 30px; border-radius: 50%; font-size: 20px; line-height: 1; color: var(--text-2); }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 18px 22px; }
.sheet-body h3 { font-size: 13px; font-weight: 700; margin: 18px 0 7px; color: var(--text); }
.sheet-body h3:first-child { margin-top: 2px; }
.sheet-body h3 small { font-weight: 400; color: var(--text-3); font-size: 11px; }
.help-p, .help-list { font-size: 12.5px; color: var(--text-2); line-height: 1.75; }
.help-list { padding-left: 18px; margin: 0; }
.help-list li { margin-bottom: 3px; }

.row-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #FBFCFE; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 13px; margin-bottom: 9px; text-align: left;
}
.row-btn span { display: flex; flex-direction: column; gap: 2px; }
.row-btn b { font-size: 13.5px; font-weight: 650; }
.row-btn small { font-size: 11px; color: var(--text-3); }
.row-btn em { font-style: normal; color: var(--brand); font-size: 16px; font-weight: 700; }
.row-btn.danger b, .row-btn.danger em { color: var(--danger); }
.row-btn:active { background: var(--brand-soft); }
.file-row { position: relative; overflow: hidden; }
.file-row input[type="file"] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.check-line { display: flex; align-items: flex-start; gap: 8px; font-size: 11.5px; color: var(--text-2); line-height: 1.6; margin: 2px 0 4px; }
.check-line input { margin-top: 2px; flex: none; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.storage-info { font-size: 11px; color: var(--text-3); line-height: 1.7; margin-top: 14px; padding: 10px 12px; background: #F7F9FD; border-radius: 10px; }

.carrier-table { display: flex; flex-direction: column; gap: 7px; margin-top: 4px; }
.carrier-row { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.carrier-row .cr-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.carrier-row b { font-size: 12.5px; }
.carrier-row .cr-url { font-size: 10.5px; color: var(--brand); word-break: break-all; margin-top: 3px; }
.carrier-row .cr-note { font-size: 11px; color: var(--text-2); margin-top: 5px; line-height: 1.6; }
.badge { font-size: 10px; padding: 2px 7px; border-radius: 6px; flex: none; font-weight: 600; }
.badge.ok { background: #E8F7EE; color: #177A42; }
.badge.manual { background: #FFF3E0; color: #9A6412; }

/* ---------- 确认框 ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(15,23,42,.46); }
.modal-box { width: 100%; max-width: 340px; background: #fff; border-radius: 16px; padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal-box h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.modal-box p { font-size: 12.5px; color: var(--text-2); line-height: 1.7; margin-bottom: 12px; }
.modal-box #confirm-input { font-size: 15px; margin-bottom: 12px; }
.modal-box .link-btn { display: block; margin: 10px auto 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom)); transform: translate(-50%, 12px);
  z-index: 80; max-width: min(92vw, 460px); background: #1B2437; color: #fff;
  border-radius: 11px; padding: 11px 15px; font-size: 12.5px; line-height: 1.6;
  box-shadow: 0 10px 30px rgba(0,0,0,.22); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast a { color: #9DB8FF; }

/* ---------- 平板 / 桌面 ---------- */
@media (min-width: 640px) {
  main { padding: 20px 20px 32px; }
  .card { padding: 18px 20px; }
  .chart { height: 260px; }
  .metric span { font-size: 26px; }
}
@media (min-width: 900px) {
  main { max-width: 960px; }
  #view-home { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch; }
  #view-home > * { margin-bottom: 0; }
  #view-home > .notice,
  #view-home > .metric-row,
  #view-home > .card-action,
  #view-home > .card-recent { grid-column: 1 / -1; }
  #btn-query { max-width: 420px; margin: 0 auto; }
  .btn-row.three { max-width: 420px; margin-left: auto; margin-right: auto; }
  .card { margin-bottom: 0; }
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%);
           width: min(560px, 92vw); border-radius: 18px; max-height: 84vh; animation: none; }
  .sheet.tall { max-height: 88vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 设置页隐私说明 */
.privacy-note { margin: 14px 0 0; padding: 12px 14px; border: 1px solid #E2E8F0;
                border-radius: 12px; background: #F8FAFF; font-size: 12.5px;
                line-height: 1.7; color: #475569; }
.privacy-note > b { display: block; margin-bottom: 6px; font-size: 13px; color: #1E293B; }
.privacy-note p { margin: 0 0 6px; }
.privacy-note p:last-child { margin-bottom: 0; }
