/* ============================================================================
   營運後台 / 商戶核銷 / 會員錢包
   同登陸頁行同一套 token，所以四個介面睇落係同一個品牌。
   白底、hairline、藥丸形、零陰影 —— 規則同 page.css 一樣。
   ========================================================================= */

body.console {
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--body-sm-size);
  line-height: var(--body-sm-lh);
}

/* ---------- 頂欄 --------------------------------------------------------- */
.c-top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px;
  min-height: 56px; padding: 8px 20px;
  background: var(--surface-page);
  border-bottom: var(--border-width) solid var(--border-subtle);
  flex-wrap: wrap;
}
.c-brand {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-primary); font-weight: var(--weight-semibold);
  font-size: var(--h4-size); text-decoration: none;
}
.c-brand img { width: 26px; height: 26px; border-radius: var(--radius-pill); }
.c-brand:hover { opacity: .6; }
.c-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.c-nav a {
  padding: 7px 14px; border-radius: var(--radius-pill);
  color: var(--text-secondary); text-decoration: none;
  font-weight: var(--weight-medium); font-size: var(--body-sm-size);
  transition: background-color var(--duration-fast) var(--ease-standard);
}
.c-nav a:hover { background: var(--surface-sunken); color: var(--text-primary); opacity: 1; }
/* 選中 = 黑底白字（後台導航唔用 accent，accent 留返俾行動） */
.c-nav a.is-active { background: var(--rh-black); color: var(--rh-white); font-weight: var(--weight-semibold); }
.c-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- 版面 --------------------------------------------------------- */
.c-main { max-width: 560px; margin: 0 auto; padding: 24px 20px 80px; display: flex; flex-direction: column; gap: 20px; }
.c-main--wide { max-width: 1200px; }

/* 成功訊息用綠色，唔用品牌 accent。
   鴨黃年代 flash 借咗 accent 做底，同下面紅色嘅 .c-error 一眼分得開。品牌轉
   紅之後如果照借，「已儲存」同「儲存失敗」會變成一淺一深兩塊紅，喺同一版
   同一個位置彈出 —— 分唔到。所以搬去 --up。 */
.c-flash {
  padding: 12px 16px; border-radius: var(--radius-md);
  background: var(--up-wash); border: var(--border-width) solid var(--up);
  color: var(--rh-black); font-weight: var(--weight-medium);
}
.c-error {
  padding: 12px 16px; border-radius: var(--radius-md);
  background: var(--surface-card); border: var(--border-width) solid var(--down);
  color: var(--down); font-weight: var(--weight-medium);
}
.c-error:empty, .c-flash:empty { display: none; }

.c-panel {
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.c-panel > h1, .c-panel > h2 {
  font-size: var(--h4-size); line-height: var(--h4-lh);
  letter-spacing: var(--tracking-cjk);
}
.c-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.c-h h1 { font-size: var(--h3-size); line-height: var(--h3-lh); letter-spacing: var(--tracking-cjk); }
.c-muted { color: var(--text-muted); font-size: var(--caption-size); }
.c-sub { color: var(--text-secondary); }

/* ---------- 統計卡 ------------------------------------------------------- */
.c-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.c-stat {
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.c-stat b {
  font-variant-numeric: tabular-nums;
  font-size: 28px; line-height: 1; letter-spacing: -0.02em;
  font-weight: var(--weight-semibold); color: var(--text-primary);
}
.c-stat span { font-size: var(--caption-size); line-height: var(--caption-lh); color: var(--text-muted); }
.c-stat a { color: inherit; }

/* ---------- 表格 --------------------------------------------------------- */
.c-tablewrap {
  overflow-x: auto;
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-md);
}
table.c-table { width: 100%; border-collapse: collapse; font-size: var(--body-sm-size); min-width: 640px; }
.c-table th, .c-table td { padding: 12px 14px; text-align: left; vertical-align: top; }
.c-table thead th {
  position: sticky; top: 0;
  background: var(--surface-sunken); color: var(--text-secondary);
  font-weight: var(--weight-semibold); white-space: nowrap;
  border-bottom: var(--border-width) solid var(--border-default);
}
.c-table tbody tr { border-bottom: var(--border-width) solid var(--border-subtle); }
.c-table tbody tr:last-child { border-bottom: none; }
.c-table tbody tr:hover { background: var(--neutral-25); }
.c-table td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.c-table td.nowrap, .c-table th.nowrap { white-space: nowrap; }
.c-empty { padding: 32px; text-align: center; color: var(--text-muted); }

/* ---------- 狀態標籤 ----------------------------------------------------- */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: var(--caption-size); font-weight: var(--weight-semibold); white-space: nowrap;
  background: var(--surface-sunken); color: var(--text-secondary);
  border: var(--border-width) solid var(--border-default);
}
.pill--new      { background: var(--surface-card); color: var(--text-primary); border-color: var(--border-strong); }
.pill--progress { background: var(--td-blue-wash); color: var(--td-blue-press); border-color: var(--td-blue-soft); }
/* good 用綠、bad 用深紅。呢兩隻 pill 成日喺同一個表格同一欄上下相鄰
   （例如活動狀態 live / ended、單據 approved / rejected），品牌轉紅之後
   good 唔可以再借 accent，否則一欄望落去全部紅色，睇唔出邊個係邊個。 */
.pill--good     { background: var(--up-wash); color: var(--up); border-color: var(--up); }
.pill--bad      { background: var(--surface-card); color: var(--down); border-color: var(--down); }
.pill--warn     { background: var(--surface-card); color: var(--warn); border-color: var(--warn); }

/* ---------- 表單 --------------------------------------------------------- */
.c-form { display: flex; flex-direction: column; gap: 14px; }
.c-field { display: flex; flex-direction: column; gap: 6px; }
.c-field > label {
  font-size: var(--body-sm-size); color: var(--text-secondary);
  font-weight: var(--weight-medium);
}
.c-field .hint { font-size: var(--caption-size); line-height: var(--caption-lh); color: var(--text-muted); }
.c-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

input.c-in, select.c-in, textarea.c-in {
  width: 100%; min-height: 44px; padding: 10px 16px;
  font-family: var(--font-sans); font-size: var(--body-size);
  color: var(--text-primary);
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-pill);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-standard),
              box-shadow var(--duration-fast) var(--ease-standard);
}
/* 多行輸入唔用藥丸形 —— 圓角太大會食咗文字 */
textarea.c-in {
  min-height: 96px; line-height: 1.6; resize: vertical;
  border-radius: var(--radius-md);
  font-family: var(--font-mono); font-size: var(--body-sm-size);
}
input.c-in::placeholder, textarea.c-in::placeholder { color: var(--text-muted); }
select.c-in {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 40px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237A7D80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 16px center;
}
input[type="file"].c-in { padding: 10px 16px; border-radius: var(--radius-md); }
:where(input.c-in, select.c-in, textarea.c-in, .c-btn):focus-visible {
  border-color: var(--focus-ring); box-shadow: var(--glow-green);
}

.c-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 22px;
  font-family: var(--font-sans); font-size: var(--body-sm-size);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-pill); border: var(--border-width) solid transparent;
  background: var(--action-primary-bg); color: var(--action-primary-fg);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: opacity var(--duration-fast) var(--ease-standard),
              transform var(--duration-instant) var(--ease-standard);
}
.c-btn:hover { opacity: .88; color: var(--action-primary-fg); }
.c-btn:active { transform: scale(var(--press-scale)); }
.c-btn:disabled { opacity: .38; cursor: not-allowed; }
.c-btn--sm { height: 32px; padding: 0 14px; font-size: var(--caption-size); }
.c-btn--ghost { background: transparent; border-color: var(--action-outline-border); color: var(--text-primary); }
.c-btn--ghost:hover { background: var(--surface-sunken); color: var(--text-primary); opacity: 1; }
.c-btn--danger { background: transparent; border-color: var(--down); color: var(--down); }
.c-btn--danger:hover { background: var(--surface-card); color: var(--down); opacity: .88; }
.c-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 摺疊區（收埋一般唔使改嘅欄位）-------------------------------- */
.c-fold {
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}
.c-fold > summary {
  cursor: pointer; list-style: none;
  padding: 12px 16px;
  font-size: var(--body-sm-size); font-weight: var(--weight-semibold);
  color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
  border-radius: var(--radius-md);
}
.c-fold > summary::-webkit-details-marker { display: none; }
/* 自己畫箭嘴，展開時轉 90 度 */
.c-fold > summary::before {
  content: ""; flex: none; width: 14px; height: 14px;
  background: var(--text-muted);
  transition: transform var(--duration-fast) var(--ease-standard);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M9 18l6-6-6-6'/></svg>") center/contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M9 18l6-6-6-6'/></svg>") center/contain no-repeat;
}
.c-fold[open] > summary::before { transform: rotate(90deg); }
.c-fold > summary:hover { opacity: .7; }
.c-fold__body { padding: 0 16px 16px; }

/* ---------- 會員錢包（手機闊度） ----------------------------------------- */
.wallet { max-width: 480px; }
.v-card {
  position: relative;
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-card); padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.v-card--used { opacity: .55; }
.v-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.v-name { font-size: var(--h4-size); line-height: var(--h4-lh); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-cjk); }
.v-merchant { font-size: var(--caption-size); line-height: var(--caption-lh); color: var(--text-muted); }
.v-amount { display: flex; align-items: baseline; gap: 2px; color: var(--text-primary); flex: none; }
.v-amount .u { font-size: var(--body-size); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.v-amount .n {
  font-variant-numeric: tabular-nums; font-size: 28px; line-height: 1;
  font-weight: var(--weight-semibold); letter-spacing: -0.02em;
}
/* 券號係客人要畀店員睇嘅嘢 —— 用品牌紅底白字，一張卡得呢一處 accent */
.v-serial {
  font-variant-numeric: tabular-nums;
  letter-spacing: .12em; font-size: 20px; font-weight: var(--weight-semibold);
  padding: 14px; text-align: center;
  background: var(--rh-green); color: var(--text-on-accent);
  border-radius: var(--radius-md);
}
.v-meta { font-size: var(--caption-size); line-height: var(--caption-lh); color: var(--text-muted); }

/* ---------- 登入頁 ------------------------------------------------------- */
.c-login { max-width: 380px; margin: 48px auto; }

/* ---------- 分頁 --------------------------------------------------------- */
.c-pager { display: flex; gap: 8px; align-items: center; justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; }
  .c-btn:active { transform: none; }
}
