:root {
  --bni-red: #cf202f;
  --bni-dark: #1b1b2f;
  --ink: #222;
  --muted: #777;
  --line: #e3e3e8;
  --bg: #f6f7f9;
  --ok: #2e7d32;
  --warn: #b26a00;
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.6;
}
a { color: var(--bni-red); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--bni-red); color: #fff; padding: .7rem 1.2rem;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 1.05rem; }
.topbar nav { display: flex; align-items: center; gap: 1rem; margin-left: auto; flex-wrap: wrap; }
.topbar nav a { color: rgba(255,255,255,.85); }
.topbar nav a:hover { color: #fff; }
.topbar .who { color: rgba(255,255,255,.7); font-size: .85rem; }
.inline { display: inline; }
.link-btn { background: none; border: none; color: rgba(255,255,255,.85); cursor: pointer; font: inherit; }
.link-btn:hover { color: #fff; }

.container { max-width: 960px; margin: 1.5rem auto; padding: 0 1.2rem; }
.foot { text-align: center; color: var(--muted); padding: 2rem 1rem; }

h1 { font-size: 1.5rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; border-left: 4px solid var(--bni-red); padding-left: .5rem; }

.card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 1.1rem 1.2rem; margin-bottom: 1rem;
}
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

label { display: block; font-weight: 600; margin: .8rem 0 .25rem; font-size: .9rem; }
input, select, textarea {
  width: 100%; padding: .55rem .6rem; border: 1px solid var(--line);
  border-radius: 7px; font: inherit; background: #fff;
}
textarea { min-height: 70px; resize: vertical; }
.hint { color: var(--muted); font-size: .8rem; font-weight: 400; }

.btn {
  display: inline-block; background: var(--bni-red); color: #fff; border: none;
  padding: .55rem 1.1rem; border-radius: 7px; cursor: pointer; font: inherit; font-weight: 600;
}
.btn:hover { opacity: .9; text-decoration: none; }
.btn.secondary { background: #555; }
.btn.small { padding: .3rem .7rem; font-size: .82rem; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); font-size: .9rem; min-width: 10em; }
th { background: #fafafc; color: var(--muted); font-weight: 600; }

.tag {
  display: inline-block; background: #eef2ff; color: #3a4a8c; border-radius: 999px;
  padding: .1rem .55rem; font-size: .78rem; margin: .1rem .15rem .1rem 0;
}
.badge { font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; font-weight: 600; }
.badge.pending { background: #fff3e0; color: var(--warn); }
.badge.ok { background: #e8f5e9; color: var(--ok); }
.badge.public { background: #e3f2fd; color: #1565c0; }
.badge.private { background: #f1f1f1; color: #777; }
.badge.b-gold { background: #fef9c3; color: #854d0e; }
.badge.b-green-light { background: #dcfce7; color: #166534; }
.badge.b-dna { background: #f3e8ff; color: #6b21a8; }
.badge.b-none { background: #ececf0; color: #666; }
.badge.b-gold, .badge.b-green-light, .badge.b-dna, .badge.b-none { border-radius: 0; white-space: nowrap; }

/* 外部夥伴照片縮圖（清單／卡片用） */
.thumb {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  display: inline-block; vertical-align: middle;
}
.thumb-empty {
  background: #eceef2; color: #b6bac4;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem;
}

/* 檔案完成率進度條（會員清單用） */
.pbar {
  display: inline-block; vertical-align: middle; width: 90px; height: 8px;
  background: #e8e8ec; border-radius: 999px; overflow: hidden; margin-right: .35rem;
}
.pbar > i { display: block; height: 100%; background: var(--bni-red); border-radius: 999px; }

/* navbar 使用者 Avatar 下拉選單（後台管理／登出收納於此） */
.avatar-menu { position: relative; }
.avatar-menu summary { list-style: none; cursor: pointer; display: inline-flex; }
.avatar-menu summary::-webkit-details-marker { display: none; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #fff; color: var(--bni-red);
  font-weight: 700; font-size: .95rem; align-items: center; justify-content: center; user-select: none;
  overflow: hidden;
}
.avatar .avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar-menu .menu {
  position: absolute; right: 0; top: calc(100% + 8px); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.15);
  min-width: 160px; padding: .3rem 0; z-index: 50;
}
.avatar-menu .menu-name {
  padding: .5rem .9rem; color: #888; font-size: .8rem;
  border-bottom: 1px solid var(--line); margin-bottom: .3rem; white-space: nowrap;
}
.avatar-menu .menu a, .avatar-menu .menu button {
  display: block; width: 100%; text-align: left; padding: .45rem .9rem;
  color: #333; background: none; border: none; font: inherit; font-size: .9rem; cursor: pointer;
}
.avatar-menu .menu a:hover, .avatar-menu .menu button:hover { background: #f5f5f7; color: #333; }

/* navbar 媒合通知鈴鐺：有媒合到才出現紅色數字 */
.bell { position: relative; display: inline-block; }
.bell-count {
  position: absolute; top: -.45rem; right: -.7rem;
  background: var(--bni-red); color: #fff; border-radius: 999px;
  font-size: .66rem; font-weight: 700; padding: 0 .32rem; line-height: 1.4;
}

/* 可點擊的統計卡：hover 黃色光暈提示可點 */
a.card { transition: box-shadow .15s ease; }
a.card:hover { box-shadow: 0 0 0 3px rgba(250, 204, 21, .55), 0 0 14px 4px rgba(250, 204, 21, .45); }

/* 開關（清單頁「只顯示自己」切換用）：on 紅 / off 灰 */
.toggle { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: #555; text-decoration: none; cursor: pointer; }
.toggle .track {
  width: 34px; height: 18px; border-radius: 999px; background: #bbb;
  position: relative; transition: background .15s; flex: none;
}
.toggle .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; transition: left .15s;
}
.toggle.on .track { background: var(--bni-red); }
.toggle.on .track::after { left: 18px; }
/* 表單版開關：內嵌 checkbox 驅動 */
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle input:checked ~ .track { background: var(--bni-red); }
.toggle input:checked ~ .track::after { left: 18px; }

/* 可點選圓籤（媒合維度勾選用） */
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .25rem 0 .6rem; }
.chip { position: relative; display: inline-block; margin: 0; cursor: pointer; font-weight: normal; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: .22rem .65rem; border: 1px solid var(--line);
  border-radius: 999px; font-size: .84rem; color: #555; background: #fff; user-select: none;
}
.chip span:hover { border-color: #4a6fa5; color: #4a6fa5; }
.chip input:checked + span { background: #4a6fa5; border-color: #4a6fa5; color: #fff; }
.chip input:focus-visible + span { outline: 2px solid #4a6fa5; outline-offset: 1px; }

.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alert.error { background: #fdecea; color: #b71c1c; }
.alert.success { background: #e8f5e9; color: var(--ok); }
.alert.info { background: #e3f2fd; color: #1565c0; }

.section-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin: .6rem 0; align-items: center; }

/* 欄位列：左欄固定寬標籤＋右欄內容（對接卡片等用） */
.kv { display: flex; gap: .7rem; padding: .18rem 0; font-size: .9rem; align-items: baseline; }
.kv .k { flex: none; width: 6.5em; color: var(--muted); font-size: .8rem; font-weight: 600; white-space: nowrap; }
.kv .v { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.score { font-weight: 700; color: var(--bni-red); }

/* ---------- RWD：手機響應式（斷點 640px） ---------- */
/* 表格橫向滑動保底 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* 內容超寬時（JS 加 is-scrollable）：顯示滑動提示字＋常駐捲軸 */
.table-wrap.is-scrollable::before {
  content: '⇆ 表格可左右滑動';
  position: sticky; left: 0; display: block;
  color: var(--muted); font-size: .72rem; padding: .2rem .1rem 0;
}
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-track { background: #eef0f3; border-radius: 999px; }
.table-wrap::-webkit-scrollbar-thumb { background: #c3c6cf; border-radius: 999px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #a8adb8; }
/* 首頁統計卡：桌機 4 欄 */
.stats-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 1.2rem; }
.stat-num { font-size: 2.4rem; font-weight: 700; color: var(--bni-red); }
/* 品牌字：手機顯示短版 */
.brand-short { display: none; }

@media (max-width: 640px) {
  .table-wrap > table { min-width: 560px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .7rem; }
  .stat-num { font-size: 2rem; }
  .brand-full { display: none; }
  .brand-short { display: inline; }
  .topbar { padding: .6rem .9rem; gap: .7rem; }

  /* 卡片化表格（活動參與者用）：手機上每列變一張直式卡 */
  .table-wrap > table.table-cards { min-width: 0; }
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; }
  .table-cards tr {
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    margin-bottom: .8rem; padding: .5rem .85rem;
  }
  .table-cards td { border-bottom: none; padding: .3rem 0; }
  .table-cards td[data-label]::before {
    content: attr(data-label); display: block;
    color: var(--muted); font-size: .74rem; font-weight: 600;
  }
}
