/* ── Google Fonts ──────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;600;700&display=swap');

/* ── 基礎重置 ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans TC', -apple-system, 'Microsoft JhengHei UI', 'Microsoft JhengHei', sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f5f5f3;
}

/* ── 登入頁（共用基底：staff.html 用） ──────────────────────── */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
}

/* ── 推薦人專用：左右分割佈局 ────────────────────────────────── */
.auth-container--referrer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  background: #0d0d0d;
  padding: 0;
}

/* ── 左側品牌區 ───────────────────────────────────────────── */
.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 64px 60px;
  background: #0d0d0d;
  position: relative;
  overflow: hidden;
}
.auth-brand::before {
  content: '';
  position: absolute;
  bottom: -80px; right: -80px;
  width: 320px; height: 320px;
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 50%;
  pointer-events: none;
}
.auth-brand::after {
  content: '';
  position: absolute;
  top: -50px; left: -50px;
  width: 200px; height: 200px;
  border: 1px solid rgba(255,255,255,.04);
  border-radius: 50%;
  pointer-events: none;
}
.auth-brand-inner { position: relative; z-index: 1; }

/* 左側品牌區 Logo 圖片 */
.auth-brand-img {
  width: 140px;
  height: auto;
  display: block;
  margin-bottom: 16px;
}

.auth-brand-logo {
  font-size: 11px;
  letter-spacing: 4px;
  font-weight: 500;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  margin-bottom: 40px;
}

/* 右側表單區小 Logo */
.auth-form-logo {
  width: 72px;
  height: auto;
  display: block;
  margin-bottom: 36px;
  opacity: 0.85;
}
.auth-brand-headline {
  font-size: 36px;
  font-weight: 300;
  color: #fff;
  line-height: 1.4;
  margin-bottom: 20px;
  letter-spacing: -0.5px;
}
.auth-brand-headline strong { font-weight: 600; }
.auth-brand-desc {
  font-size: 14px;
  color: rgba(255,255,255,.5);
  line-height: 1.9;
  margin-bottom: 48px;
}
.auth-perks {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-perks li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: rgba(255,255,255,.65);
  letter-spacing: 0.3px;
}
.perk-dot {
  display: inline-block;
  width: 5px; height: 5px;
  background: #BE1E2D;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── 右側表單區 ───────────────────────────────────────────── */
.auth-form-side {
  background: #fff;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 60px;
  overflow-y: auto;
  min-height: 100vh;
}

/* ── Auth Card ─────────────────────────────────────────────── */
.auth-card { width: 100%; max-width: 420px; }

/* ── 員工專用：深色全版佈局 ─────────────────────────────────── */
.auth-container--staff {
  background: #0d0d0d;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 20px;
  position: relative;
  overflow: hidden;
}
.auth-container--staff::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

.staff-brand-mark {
  text-align: center;
  margin-bottom: 52px;
  position: relative;
}
.staff-logo-img {
  width: 120px;
  height: auto;
  display: block;
  margin: 0 auto 14px;
}
.staff-logo-divider {
  width: 36px;
  height: 2px;
  background: #BE1E2D;
  margin: 0 auto 12px;
}
.staff-logo-sub {
  font-size: 11px;
  letter-spacing: 3px;
  color: rgba(255,255,255,.3);
  text-transform: uppercase;
}

.auth-container--staff .auth-card {
  background: transparent;
  border: none;
  padding: 0;
  width: 100%;
  max-width: 360px;
}
.auth-container--staff .auth-card-header {
  margin-bottom: 28px;
}
.auth-container--staff .auth-card h1 {
  color: #fff;
  font-size: 22px;
}
.auth-container--staff .auth-label-small {
  color: #BE1E2D;
}
.auth-container--staff .auth-card label {
  color: rgba(255,255,255,.35);
}
.auth-container--staff .auth-card input {
  color: #fff;
  border-bottom-color: rgba(255,255,255,.15);
}
.auth-container--staff .auth-card input:focus {
  border-bottom-color: #BE1E2D;
}
.auth-container--staff .auth-card input::placeholder {
  color: rgba(255,255,255,.15);
}
.auth-container--staff .auth-card button[type=submit] {
  background: #fff;
  color: #111;
  margin-top: 32px;
}
.auth-container--staff .auth-card button[type=submit]:hover {
  background: #BE1E2D;
  color: #fff;
}
.auth-container--staff .link {
  color: rgba(255,255,255,.35);
  margin-top: 16px;
}
.auth-container--staff .link:hover { color: #BE1E2D; }
.auth-container--staff .error   { color: #ff6b6b; }
.auth-container--staff .success { color: #4ade80; }

.auth-card-header { margin-bottom: 32px; }
.auth-label-small {
  font-size: 11px;
  letter-spacing: 3px;
  color: #BE1E2D;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 500;
}
.auth-card h1 {
  font-size: 24px;
  font-weight: 600;
  color: #111;
  letter-spacing: -0.4px;
  margin-bottom: 0;
  text-align: left;
}
.auth-card h2 { font-size: 18px; font-weight: 600; margin-bottom: 20px; color: #111; }

.auth-card label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #999;
  margin: 20px 0 8px;
}
.auth-card input {
  width: 100%;
  border: none;
  border-bottom: 1px solid #ddd;
  padding: 10px 0;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  background: transparent;
  color: #111;
  transition: border-color .2s;
  border-radius: 0;
  -webkit-appearance: none;
}
.auth-card input:focus { border-bottom-color: #BE1E2D; }
.auth-card input::placeholder { color: #ccc; font-size: 13px; }
.auth-card button[type=submit] {
  margin-top: 28px;
  width: 100%;
  background: #111;
  color: #fff;
  border: none;
  padding: 15px;
  font-size: 12px;
  font-family: inherit;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s;
  border-radius: 0;
}
.auth-card button[type=submit]:hover { background: #BE1E2D; }
.auth-card button[type=submit]:disabled { opacity: .5; cursor: default; }

/* Tab 切換 */
.tab-group {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border-bottom: 1px solid #e8e8e8;
}
.tab-group button {
  flex: 1;
  padding: 12px 0;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  color: #aaa;
  letter-spacing: 0.3px;
  transition: all .15s;
}
.tab-group button.active {
  color: #111;
  border-bottom-color: #BE1E2D;
  font-weight: 600;
}

/* ── 膠囊分頁（加購商品子分頁） ─────────────────────────── */
.pill-tabs {
  display: inline-flex;
  gap: 4px;
  background: #fff;
  padding: 5px;
  border-radius: 12px;
  margin-bottom: 32px;
  border: 1px solid #eaeaea;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.pill-tabs button {
  border: none;
  padding: 10px 28px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: #94a3b8;
  font-family: inherit;
}
.pill-tabs button:hover {
  background: #f8f9fa;
  color: #475569;
}
.pill-tabs button.active {
  background: linear-gradient(135deg, #BE1E2D, #e03244);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}
.pill-tabs button.active:hover {
  background: linear-gradient(135deg, #a51a28, #c92d3d);
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}
.pill-tabs button svg {
  width: 18px;
  height: 18px;
}
.pill-tabs button:not(.active) svg {
  opacity: 0.5;
}

/* 小型膠囊分頁（分類篩選、語言切換等） */
.pill-tabs--sm button {
  padding: 6px 16px;
  font-size: 14px;
  border-radius: 6px;
}
.pill-tabs--sm {
  border-radius: 10px;
  padding: 4px;
}

/* 深色背景上的語言切換（Sidebar） */
.lang-switch {
  display: flex;
  gap: 4px;
  margin: 0 12px 4px;
  background: rgba(255,255,255,.06);
  padding: 4px;
  border-radius: 8px;
}
.lang-switch button {
  flex: 1;
  border: none;
  background: transparent;
  color: #888;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  transition: all .2s;
}
.lang-switch button:hover {
  background: rgba(255,255,255,.08);
  color: #c8c8c8;
}
.lang-switch button.active {
  background: linear-gradient(135deg, #BE1E2D, #e03244);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.link { margin-top: 16px; color: #BE1E2D; cursor: pointer; font-size: 12px; letter-spacing: 0.5px; }
.error   { color: #BE1E2D; margin-top: 8px; font-size: 13px; }
.success { color: #16a34a; margin-top: 8px; font-size: 13px; }

/* ── 主框架 ────────────────────────────────────────────────── */
.app-layout { display: grid; grid-template-columns: 220px 1fr; height: 100vh; overflow-y: hidden; }

/* ── 側邊欄 ────────────────────────────────────────────────── */
.sidebar { background: #0d0d0d; color: #c8c8c8; display: flex; flex-direction: column; padding: 0; overflow-y: auto; }
.brand { padding: 20px 20px 14px; font-weight: 700; font-size: 14px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); letter-spacing: 2px; text-transform: uppercase; }
.user-info { padding: 12px 20px; display: flex; flex-direction: column; gap: 4px; border-bottom: 1px solid rgba(255,255,255,.08); }
.role-badge { font-size: 11px; background: rgba(255,255,255,.1); padding: 2px 6px; border-radius: 2px; width: fit-content; letter-spacing: 0.5px; }
.sidebar ul { list-style: none; padding: 8px 0; flex: 1; }
.sidebar li { padding: 10px 20px; cursor: pointer; border-radius: 0; transition: background .15s; font-size: 13px; letter-spacing: 0.3px; }
.sidebar li:hover { background: rgba(255,255,255,.06); }
.sidebar li.active { background: #BE1E2D; color: #fff; }
.sidebar .nav-group-title { font-size: 10px; font-weight: 700; color: rgba(255, 255, 255, 0.35); letter-spacing: 1.5px; margin: 16px 0 6px 20px; padding: 0; cursor: default; pointer-events: none; list-style: none; text-transform: uppercase; }
.sidebar .nav-group-title:hover { background: transparent; }
.logout-btn { margin: 12px; border: none; background: rgba(255,255,255,.08); color: #c8c8c8; border-radius: 6px; padding: 8px; cursor: pointer; font-size: 13px; font-family: inherit; transition: background .15s; }
.logout-btn:hover { background: rgba(255,255,255,.15); }

/* ── 主內容 ────────────────────────────────────────────────── */
.main-content { padding: 28px 32px; overflow-y: auto; overflow-x: auto; background: #f5f5f3; min-width: 0; }
.page-title { font-size: 20px; font-weight: 700; color: #111; margin-bottom: 20px; letter-spacing: -0.3px; }

/* ── 總覽卡片 ──────────────────────────────────────────────── */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; }
.card { background: #fff; border-radius: 2px; padding: 24px 28px; box-shadow: none; border: 1px solid #e8e8e8; }
.card-label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: #999; margin-bottom: 12px; }
.card-value { font-size: 28px; font-weight: 700; color: #BE1E2D; letter-spacing: -1px; }

/* ── 工具列 ────────────────────────────────────────────────── */
.toolbar { margin-bottom: 12px; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar input, .filter-bar select {
  border: 1px solid #e0e0e0; border-radius: 2px; padding: 6px 10px; font-size: 13px; background: #fff; font-family: inherit; }

/* ── 表格 ──────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 2px; overflow: hidden; border: 1px solid #e8e8e8; }
.data-table th { background: #fafafa; padding: 10px 12px; text-align: left; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: #999; font-weight: 600; border-bottom: 1px solid #e8e8e8; white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #f5f5f3; font-size: 13px; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }
.text-right { text-align: right; }
.row-disabled td { color: #bbb; }

/* ── 狀態 Badge ────────────────────────────────────────────── */
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 2px; font-weight: 500; letter-spacing: 0.5px; white-space: nowrap; }
.badge-gray   { background: #f5f5f5; color: #999; }
.badge-blue   { background: #e8f0fe; color: #1a56db; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-orange { background: #fff3e0; color: #b45309; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }

/* ── 物流資訊卡（Modal 置頂確認資訊用） ─────────────────────── */
.info-block {
  background: #f8f8f8;
  border: 1px solid #e8e8e8;
  border-radius: 2px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.info-block-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.info-block-row + .info-block-row {
  border-top: 1px solid #f0f0f0;
  margin-top: 4px;
  padding-top: 8px;
}
.info-block-label {
  font-size: 11px;
  color: #999;
  letter-spacing: 1px;
  text-transform: uppercase;
  min-width: 60px;
  flex-shrink: 0;
}

/* ── 複製按鈕 ────────────────────────────────────────────────── */
.copy-btn {
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  color: #555;
  font-family: inherit;
  transition: background .15s, color .15s;
  flex-shrink: 0;
  margin-left: auto;
}
.copy-btn:hover { background: #BE1E2D; color: #fff; border-color: #BE1E2D; }

/* ── 按鈕 ──────────────────────────────────────────────────── */
.btn-primary  { background: linear-gradient(135deg, #BE1E2D, #e03244); color: #fff; border: none; border-radius: 6px; padding: 8px 16px; cursor: pointer; font-size: 13px; font-family: inherit; font-weight: 600; transition: all .2s ease; box-shadow: 0 2px 8px rgba(0,0,0,0.08); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-primary:hover { background: linear-gradient(135deg, #a51a28, #c92d3d); box-shadow: 0 4px 12px rgba(0,0,0,0.12); transform: translateY(-1px); }
.btn-secondary { background: #f5f5f5; color: #333; border: 1px solid #e0e0e0; border-radius: 6px; padding: 8px 16px; cursor: pointer; font-size: 13px; font-family: inherit; font-weight: 600; transition: all .2s ease; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-secondary:hover { background: #ebebeb; border-color: #d0d0d0; }
.btn-sm       { padding: 4px 10px; font-size: 12px; border: none; border-radius: 6px; cursor: pointer; margin: 0 2px; font-family: inherit; font-weight: 600; transition: all .15s ease; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.btn-sm:hover { transform: translateY(-1px); }
.btn-success  { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger   { background: #BE1E2D; color: #fff; }
.btn-danger:hover { background: #a01825; }
.btn-cancel  { background: #92400E; color: #fff; }
.btn-cancel:hover { background: #78350F; }

/* ── 分頁 ──────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: #999; }
.pagination button { padding: 4px 10px; border: 1px solid #e0e0e0; border-radius: 2px; cursor: pointer; background: #fff; font-size: 12px; font-family: inherit; }
.pagination button:disabled { opacity: .5; cursor: default; }

/* ── 其他 ──────────────────────────────────────────────────── */
.empty { color: #bbb; padding: 40px 0; text-align: center; font-size: 13px; }
.upload-area { background: #fff; border-radius: 2px; padding: 24px; max-width: 600px; border: 1px solid #e8e8e8; }
.upload-area p  { color: #999; font-size: 13px; margin-bottom: 12px; }
.upload-area input[type=file] { display: block; margin: 12px 0; }
.result-box { background: #0d0d0d; color: #a3e635; padding: 16px; border-radius: 2px; font-size: 12px; margin-top: 16px; overflow: auto; max-height: 300px; }
code { background: #f5f5f5; padding: 1px 4px; border-radius: 2px; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card { background: #fff; border-radius: 2px; padding: 32px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.modal-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 20px; letter-spacing: -0.3px; }
.modal-card label { display: block; font-size: 11px; font-weight: 500; letter-spacing: 1.5px; text-transform: uppercase; color: #999; margin: 16px 0 6px; }
.modal-card input {
  width: 100%;
  border: none;
  border-bottom: 1px solid #ddd;
  border-radius: 0;
  padding: 8px 0;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: transparent;
  color: #111;
  transition: border-color .2s;
}
.modal-card input:focus { border-bottom-color: #BE1E2D; }
.modal-card select {
  width: 100%;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #fff;
  color: #111;
}
.modal-card select:focus { border-color: #BE1E2D; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* ── 手機版頂部導覽列（桌機隱藏）──────────────────────────────── */
.mobile-topbar {
  display: none;
}
.mobile-brand-logo {
  height: 28px;
  width: auto;
  display: block;
}
.mobile-username {
  font-size: 12px;
  color: rgba(255,255,255,.5);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hamburger-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
}
.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transition: opacity .15s;
}
.hamburger-btn:hover span { opacity: .7; }

/* 側邊欄遮罩（手機滑出時的半透明背景） */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 250;
}
.sidebar-overlay.show { display: block; }

/* ── 響應式 ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  /* 上下堆疊：深色橫幅 + 白色表單 */
  .auth-container--referrer {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    background: #0d0d0d;
  }

  /* 品牌區改為頂部橫幅（不再隱藏） */
  .auth-brand {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 18px 28px;
    min-height: unset;
  }
  .auth-brand::before,
  .auth-brand::after { display: none; }

  .auth-brand-inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
  }
  .auth-brand-img {
    width: 52px;
    margin-bottom: 0;
  }
  .auth-brand-logo {
    margin-bottom: 0;
    font-size: 10px;
    letter-spacing: 3px;
  }

  /* 手機版隱藏標語與 bullets（空間不足） */
  .auth-brand-headline,
  .auth-brand-desc,
  .auth-perks { display: none; }

  /* 表單區：白色背景，縮減 padding */
  .auth-form-side {
    min-height: unset;
    padding: 36px 28px 52px;
    background: #fff;
  }

  /* 表單頂部小 logo 在手機版隱藏（橫幅已提供品牌識別） */
  .auth-form-logo { display: none; }
}
@media (max-width: 768px) {
  /* 主框架改為直向 flex，sidebar 脫離文件流 */
  .app-layout {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
    min-height: 100vh;
  }

  /* 手機版頂部列：顯示品牌 + 漢堡選單 */
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0d0d0d;
    padding: 0 20px;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
  }

  /* Sidebar 改為固定滑入式抽屜，預設隱藏在畫面左側 */
  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;           /* iOS 修正：排除網址列高度 */
    width: 260px;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow-y: auto;         /* 萬一內容超出可滾動 */
    overscroll-behavior: contain;
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }

  /* 登出按鈕：固定在 sidebar 底部，加上 iPhone 安全區間距 */
  .logout-btn {
    margin-top: auto;
    margin-bottom: max(12px, env(safe-area-inset-bottom));
    border-radius: 0;
    flex-shrink: 0;
  }

  /* 主內容滿版，取消側欄預留空間 */
  .main-content {
    padding: 20px 16px;
    flex: 1;
  }

  /* 表格改為卡片式排版：每列一張卡，每格用 data-label 顯示欄位名 */
  .data-table { border: none; background: transparent; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    border: 1px solid #e8e8e8;
    border-radius: 2px;
    background: #fff;
    margin-bottom: 10px;
  }
  .data-table tr:hover td { background: transparent; }
  .data-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: right;
    padding: 9px 14px;
    border-bottom: 1px solid #f5f5f3;
    white-space: normal;
  }
  .data-table tr td:last-child { border-bottom: none; }
  .data-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: #999;
    text-align: left;
  }
}

/* ── Password Toggle ───────────────────────────────────────── */
.password-wrap { position: relative; }
.password-wrap input { padding-right: 52px; }
.pw-toggle { position: absolute; right: 0; top: 50%; transform: translateY(-50%); background: none; border: none; color: #BE1E2D; font-size: 12px; cursor: pointer; padding: 2px 4px; font-family: inherit; }
.pw-toggle:hover { text-decoration: underline; }

.order-badge { margin-top: 8px; padding: 8px 12px; background: #fff8f8; border-left: 3px solid #BE1E2D; color: #BE1E2D; font-size: 13px; border-radius: 0; }
.error-msg   { margin-top: 8px; padding: 8px 12px; background: #fff8f8; border-left: 3px solid #BE1E2D; color: #BE1E2D; font-size: 13px; border-radius: 0; }

/* ── Referrer Autocomplete ─────────────────────────────────── */
.referrer-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid #e0e0e0; border-radius: 2px; box-shadow: 0 8px 24px rgba(0,0,0,.1); max-height: 200px; overflow-y: auto; z-index: 200; margin-top: 2px; }
.referrer-option { padding: 10px 12px; font-size: 14px; cursor: pointer; color: #111; }
.referrer-option:hover { background: #fafafa; }

.settings-form { max-width: 420px; background: #fff; border-radius: 2px; padding: 28px; border: 1px solid #e8e8e8; margin-top: 16px; }
.settings-hint { color: #999; font-size: 13px; margin-bottom: 20px; }
.settings-row  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.settings-row label { font-weight: 600; font-size: 14px; }
.settings-row input { width: 140px; border: 1px solid #e0e0e0; border-radius: 2px; padding: 7px 10px; font-size: 14px; text-align: right; font-family: inherit; }
.settings-row input:focus { outline: none; border-color: #BE1E2D; }
.settings-row-sub { padding-left: 16px; background: #fafafa; border-radius: 2px; margin-bottom: 4px; }
.settings-tier-actions { display: flex; gap: 8px; margin: 4px 0 16px; }
.settings-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.save-success { color: #16a34a; font-size: 13px; font-weight: 600; }
.btn-danger-soft { color: #BE1E2D; border-color: #fecaca; }
.btn-danger-soft:hover:not(:disabled) { background: #fff8f8; }

/* ── CAPTCHA ───────────────────────────────────────────────── */
.captcha-section { margin-top: 4px; }
.captcha-row { display: flex; align-items: center; gap: 10px; margin: 8px 0 10px; }
.captcha-box { font-size: 24px; font-weight: 700; letter-spacing: 10px; color: #BE1E2D; background: #fff8f8; border: 1px solid #f5c6cb; border-radius: 2px; padding: 8px 20px; text-align: center; min-width: 140px; user-select: none; }
.captcha-refresh { background: none; border: 1px solid #e0e0e0; border-radius: 2px; padding: 6px 12px; cursor: pointer; color: #999; font-size: 13px; white-space: nowrap; font-family: inherit; }
.captcha-refresh:hover { background: #fafafa; }

/* ── 全域 Toast ─────────────────────────────────────────────── */
#global-toast {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: #111; color: #fff;
  padding: 18px 36px; border-radius: 2px;
  font-size: 15px; font-weight: 500; white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 9999;
  letter-spacing: 0.5px;
}
#global-toast.show {
  opacity: 1; transform: translate(-50%, -50%) scale(1);
}

/* ── 上傳 Spinner ───────────────────────────────────────────── */
.upload-spinner {
  width: 20px; height: 20px; flex-shrink: 0;
  border: 2px solid #BFDBFE;
  border-top-color: #2563EB;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 成效儀表板 ───────────────────────────────────────────────── */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.dash-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  border: 1px solid #e8e8e8;
  text-align: center;
}
.dash-card-label {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 8px;
}
.dash-card-value {
  font-size: 28px;
  font-weight: 700;
  color: #111;
}
.chart-section {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e8e8e8;
  padding: 20px;
  margin-bottom: 20px;
}
.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 16px;
}
.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}
.chart-half {
  flex: 1;
  min-width: 0;
}
.chart-half .chart-container {
  height: 260px;
}
.dashboard-row {
  display: flex;
  gap: 20px;
}
.empty {
  padding: 60px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
}

@media (max-width: 768px) {
  .dashboard-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-row {
    flex-direction: column;
  }
  .dash-card-value {
    font-size: 22px;
  }
}

.popup-header {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.8;
}
.popup-referred {
  font-size: 1.2em;
  font-weight: 700;
  color: #1e293b;
  background: #f0f9ff;
  border-left: 4px solid #0ea5e9;
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 10px;
  line-height: 1.5;
}
.popup-referred .referred-name {
  font-weight: 800;
  color: #0c4a6e;
}
.popup-amounts {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}
.amount-box {
  flex: 1;
  text-align: center;
  background: #f8f9fa;
  border-radius: 6px;
  padding: 12px;
}
.amount-label {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 4px;
  font-weight: 500;
}
.amount-value {
  font-size: 15px;
  font-weight: 700;
  color: #111;
}

.timeline-horizontal {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  padding: 8px 0 16px;
  overflow-x: auto;
}
.tl-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
  min-width: 72px;
  position: relative;
  z-index: 1;
}
.tl-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #cbd5e1;
  margin-bottom: 8px;
  transition: all .2s;
}
.tl-label {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 4px;
  white-space: nowrap;
}
.tl-date {
  font-size: 12px;
  color: #111;
  font-weight: 600;
}

.tl-connector {
  flex: 1;
  height: 2px;
  background: #e2e8f0;
  margin-top: 9px;
  min-width: 16px;
  position: relative;
  z-index: 0;
}
.tl-connector::after {
  content: '';
  position: absolute;
  right: -1px;
  top: -3px;
  width: 0;
  height: 0;
  border-left: 5px solid #e2e8f0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.tl-done .tl-dot {
  background: #22c55e;
  border-color: #22c55e;
}
.tl-done .tl-label {
  color: #166534;
}
.tl-current .tl-dot {
  background: #BE1E2D;
  border-color: #BE1E2D;
  box-shadow: 0 0 0 3px rgba(190,30,45,0.2);
}
.tl-current .tl-label {
  color: #BE1E2D;
  font-weight: 600;
}
.tl-future .tl-dot {
  background: #fff;
  border-color: #e2e8f0;
}
.tl-future .tl-label {
  color: #cbd5e1;
}
.tl-error .tl-dot {
  background: #ef4444;
  border-color: #ef4444;
}
.tl-error .tl-label {
  color: #b91c1c;
  font-weight: 600;
}
.tl-na {
  visibility: hidden;
}

.tl-conn-done {
  background: #22c55e;
}
.tl-conn-done::after {
  border-left-color: #22c55e;
}
.tl-conn-current {
  background: linear-gradient(90deg, #22c55e 0%, #BE1E2D 100%);
}
.tl-conn-current::after {
  border-left-color: #BE1E2D;
}
.tl-conn-future {
  background: #e2e8f0;
}
.tl-conn-future::after {
  border-left-color: #e2e8f0;
}
.tl-conn-error {
  background: #ef4444;
}
.tl-conn-error::after {
  border-left-color: #ef4444;
}
.tl-conn-na {
  visibility: hidden;
}

@media (max-width: 640px) {
  .timeline-horizontal {
    padding: 8px 4px 16px;
  }
  .tl-node {
    min-width: 56px;
  }
  .tl-label {
    font-size: 10px;
  }
  .tl-date {
    font-size: 11px;
  }
  .popup-amounts {
    flex-direction: column;
    gap: 8px;
  }
}
