/* ============================================================
   资源对接中心 · 共享样式
   明亮主题 · 移动端优先 · 商务亲和风
   ============================================================ */
:root {
  --brand: #c8321e;          /* 主色：中国红（喜庆、信任） */
  --brand-2: #e8542f;
  --brand-soft: #fdf1ee;
  --ink: #1f2328;
  --ink-2: #4a5159;
  --ink-3: #8a929b;
  --line: #e8ebef;
  --bg: #f6f7f9;
  --card: #ffffff;
  --ok: #1a9c6b;
  --ok-soft: #e8f7f0;
  --warn: #b8860b;
  --warn-soft: #fdf6e3;
  --blue: #2f6fd0;
  --blue-soft: #eaf1fc;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 8px rgba(20, 30, 45, .06), 0 12px 28px rgba(20, 30, 45, .05);
  --shadow-sm: 0 1px 3px rgba(20, 30, 45, .07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

.wrap { max-width: 680px; margin: 0 auto; padding: 0 16px 48px; }
.wide { max-width: 1200px; }

/* ---------- 顶部品牌条 ---------- */
.topbar {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  padding: 22px 20px 26px;
  position: relative;
  overflow: hidden;
}
.topbar::after {
  content: ""; position: absolute; right: -40px; top: -40px;
  width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255,255,255,.09);
}
.topbar .brand-main {
  display: flex; align-items: center; gap: 12px;
  position: relative; z-index: 1;
}
.topbar .brand-logo {
  height: 44px; width: auto; max-width: 46vw; object-fit: contain;
  background: #fff; border-radius: 8px; padding: 4px 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  flex: 0 0 auto;
}
.topbar .brand-text { min-width: 0; }
.topbar .brand-name { font-size: 21px; font-weight: 700; letter-spacing: .5px; }
.topbar .brand-slogan { font-size: 13px; opacity: .92; margin-top: 4px; }
.topbar .back {
  display: inline-block; color: #fff; opacity: .9; font-size: 13px;
  margin-bottom: 10px; cursor: pointer;
  position: relative; z-index: 1;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--line);
  padding: 18px; margin-top: 14px;
}
.card-title { font-size: 16px; font-weight: 700; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.card-sub { font-size: 12.5px; color: var(--ink-3); margin: 0 0 14px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); font-weight: 400; margin-left: 6px; }
.req { color: var(--brand); }
input[type=text], input[type=tel], input[type=number], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; min-height: 62px; line-height: 1.55; }
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%238a929b' stroke-width='1.6' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* 分段选择 */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label {
  flex: 1; min-width: 90px; text-align: center; padding: 9px 10px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font-size: 13.5px; cursor: pointer; background: #fff; transition: all .15s; font-weight: 500;
}
.seg input { display: none; }
/* 兼容不支持 :has() 的浏览器：JS 给 label 加 .on */
.seg label.on,
.seg label:has(input:checked) {
  border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 700;
}

/* 动态条目 */
.item-box {
  border: 1.5px dashed var(--line); border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 10px; background: #fcfcfd;
}
.item-box .item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.item-box .item-head b { font-size: 13px; color: var(--ink-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid2 .field { margin-bottom: 8px; }
.item-box .field:last-child { margin-bottom: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: var(--radius-sm); border: none;
  background: var(--brand); color: #fff; font-weight: 600; font-size: 15px;
  cursor: pointer; transition: opacity .15s, transform .05s; width: 100%;
}
.btn:active { transform: scale(.99); }
.btn:hover { opacity: .93; }
.btn-lg { padding: 15px; font-size: 16.5px; border-radius: 12px; }
.btn-ghost { background: #fff; color: var(--ink-2); border: 1.5px solid var(--line); }
.btn-ghost:hover { background: #fafbfc; }
.btn-mini { padding: 7px 12px; font-size: 13px; width: auto; border-radius: 8px; }
.btn-danger { background: #fff; color: #d33; border: 1.5px solid #f3c9c9; }
.btn-row { display: flex; gap: 10px; }

/* 删除小按钮 */
.del-x {
  width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-3); cursor: pointer; font-size: 15px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.del-x:hover { color: #d33; border-color: #f3c9c9; background: #fff5f5; }

/* ---------- 徽标 / 标签 ---------- */
.tag {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 600; line-height: 1.5;
}
.tag-supply { background: var(--ok-soft); color: var(--ok); }
.tag-need { background: var(--blue-soft); color: var(--blue); }
.tag-cat { background: #f1f3f6; color: var(--ink-2); font-weight: 500; }
.tag-share { background: var(--warn-soft); color: var(--warn); }

/* ---------- 数据统计条 ---------- */
.statbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 8px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat .n { font-size: 22px; font-weight: 800; color: var(--brand); line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* ---------- 列表项 ---------- */
.rec {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px; margin-top: 10px; box-shadow: var(--shadow-sm);
}
.rec.hidden { display: none; }
.rec-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.rec-head h3 { margin: 0; font-size: 15.5px; font-weight: 700; }
.rec-meta { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.rec-block { margin-top: 11px; padding-top: 11px; border-top: 1px dashed var(--line); }
.rec-block h4 { font-size: 12.5px; margin: 0 0 7px; color: var(--ink-3); font-weight: 700; letter-spacing: .3px; }
.pitem { padding: 8px 10px; background: #fafbfc; border-radius: 9px; margin-bottom: 6px; border-left: 3px solid var(--ok); }
.pitem.need { border-left-color: var(--blue); background: #f7f9fd; }
.pitem .pname { font-weight: 600; font-size: 14px; }
.pitem .pprice { font-size: 13px; color: var(--brand); font-weight: 700; margin-top: 2px; }
.pitem .pdesc { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

/* ---------- 匹配 ---------- */
.match {
  display: flex; align-items: stretch; gap: 10px; padding: 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
  margin-bottom: 10px; box-shadow: var(--shadow-sm);
}
.match .side { flex: 1; min-width: 0; }
.match .arrow { display: flex; align-items: center; color: var(--brand); font-size: 18px; font-weight: 700; }
.match .who { font-size: 11.5px; color: var(--ink-3); margin-bottom: 2px; }
.match .what { font-size: 13.5px; font-weight: 600; }
.match .score { font-size: 11.5px; color: var(--ok); font-weight: 700; margin-top: 4px; }

/* ---------- 工具条 ---------- */
.toolbar { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { flex: 1; min-width: 130px; padding: 9px 11px; }
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 4px; margin-top: 10px; -webkit-overflow-scrolling: touch; }
.chip {
  padding: 6px 13px; border-radius: 20px; background: #fff; border: 1px solid var(--line);
  font-size: 13px; white-space: nowrap; cursor: pointer; color: var(--ink-2); font-weight: 500;
}
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); display: flex; max-width: 680px; margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-align: center; padding: 9px 0 8px; font-size: 11px;
  color: var(--ink-3); display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabbar a.active { color: var(--brand); font-weight: 700; }
.tabbar svg { width: 21px; height: 21px; }
.has-tab { padding-bottom: 74px; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--ink-3); }
.empty .big { font-size: 40px; opacity: .5; }
.empty p { margin: 10px 0 0; font-size: 14px; }

/* ---------- 提示条 ---------- */
.notice {
  padding: 11px 13px; border-radius: var(--radius-sm); font-size: 13px;
  margin-top: 12px; line-height: 1.55;
}
.notice-info { background: var(--blue-soft); color: #23508f; }
.notice-ok { background: var(--ok-soft); color: #146b4a; }
.notice-warn { background: var(--warn-soft); color: #8a6508; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(20,26,35,.5); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center; opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.mask.show { opacity: 1; pointer-events: auto; }
.sheet {
  background: #fff; width: 100%; max-width: 520px; border-radius: 18px 18px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto;
  transform: translateY(20px); transition: transform .2s;
}
.mask.show .sheet { transform: translateY(0); }
.sheet h3 { margin: 0 0 4px; font-size: 17px; }

/* ---------- 文案框 ---------- */
.copybox {
  background: #fafbfc; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; font-size: 14px; line-height: 1.75; white-space: pre-wrap;
  max-height: 320px; overflow-y: auto; color: var(--ink-2);
}

/* ---------- 海报预览 ---------- */
.poster-stage { display: flex; justify-content: center; margin-top: 14px; }
#posterCanvas { max-width: 100%; border-radius: 12px; box-shadow: var(--shadow); }

/* ---------- 二维码 ---------- */
#qrcode { display: flex; justify-content: center; padding: 14px 0 4px; }
#qrcode img, #qrcode canvas { border-radius: 10px; }

/* ---------- 响应式 ---------- */
@media (min-width: 760px) {
  .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
  .statbar { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 400px) {
  .statbar { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- 后台口令门禁 ---------- */
body.gated { overflow: hidden; }
.gate {
  position: fixed; inset: 0; z-index: 200;
  background: linear-gradient(150deg, var(--brand) 0%, var(--brand-2) 100%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gate-card {
  background: #fff; border-radius: 20px; padding: 30px 24px 24px;
  width: 100%; max-width: 340px; text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.gate-card.shake { animation: gateShake .38s; }
@keyframes gateShake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
.gate-lock { font-size: 34px; line-height: 1; }
.gate-card h2 { margin: 12px 0 4px; font-size: 19px; font-weight: 800; }
.gate-sub { margin: 0 0 18px; font-size: 13px; color: var(--ink-3); }
.gate-card input {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); text-align: center; letter-spacing: 2px;
  font-size: 16px; outline: none; margin-bottom: 12px;
}
.gate-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.gate-err { color: #d33; font-size: 12.5px; min-height: 18px; margin-top: 8px; }
.gate-mode { font-size: 11.5px; color: var(--ink-3); margin-top: 10px; }
.gate-public { display: inline-block; margin-top: 14px; font-size: 13px; color: var(--ink-3); }

/* ---------- 同步状态条 ---------- */
.sync-banner {
  font-size: 12px; padding: 6px 14px; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  position: relative; z-index: 20;
}
.sync-banner .dot {
  width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto;
}
.sync-banner.ok { background: #eaf7f1; color: #0f8a5f; }
.sync-banner.ok .dot { background: #0f8a5f; box-shadow: 0 0 0 3px rgba(15,138,95,.15); }
.sync-banner.warn { background: #fff6e8; color: #a86a12; }
.sync-banner.warn .dot { background: #d9901a; }
.sync-banner a { color: inherit; text-decoration: underline; font-weight: 600; }

/* ---------- 云端连接卡片（设置页） ---------- */
.cloud-state {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px; font-size: 13.5px; margin-bottom: 12px;
}
.cloud-state.ok { background: #eaf7f1; color: #0b6b4a; border: 1px solid #cdeade; }
.cloud-state.warn { background: #fff6e8; color: #8a5a0f; border: 1px solid #f3e0bd; }
.cloud-state .cs-ico { font-size: 20px; }
.cloud-state b { display: block; margin-bottom: 2px; }

/* ---------- 主题色选择（设置页） ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-opt {
  border: 2px solid var(--line); border-radius: 12px; padding: 10px 8px;
  text-align: center; cursor: pointer; background: #fff; transition: all .15s;
}
.theme-opt.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.theme-opt .dot {
  width: 34px; height: 34px; border-radius: 50%; margin: 0 auto 7px;
}
.theme-opt .nm { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.theme-opt.on .nm { color: var(--brand); }

/* ---------- 品牌预览卡 ---------- */
.brand-preview {
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}
.brand-preview .bp-top {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff; padding: 16px 18px; position: relative; overflow: hidden;
}
.brand-preview .bp-top::after {
  content: ""; position: absolute; right: -30px; top: -30px;
  width: 110px; height: 110px; border-radius: 50%; background: rgba(255,255,255,.1);
}
.brand-preview .bp-name { font-size: 18px; font-weight: 700; }
.brand-preview .bp-slogan { font-size: 12.5px; opacity: .92; margin-top: 3px; }
.brand-preview .bp-body { background: #fafbfc; padding: 12px 18px; font-size: 12.5px; color: var(--ink-3); }

/* ---------- 打印 ---------- */
@media print {
  .topbar, .tabbar, .toolbar, .btn, .no-print, .sync-banner { display: none !important; }
}
