/*
 * 管理後台。沿用 style.css 的設計 token（顏色、圓角、字體），只加後台自己的版面。
 *
 * 跟問答介面刻意長得不一樣：問答是手機優先的對話，後台是桌機上的資料表。
 * 同一套色，不同的密度。
 */

#admin {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ── 頁首與分頁 ── */

.admin-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 0 14px;
  flex-wrap: wrap;
}
.admin-head h1 {
  font-family: var(--font-en);
  font-size: 19px;
  font-weight: 800;
  margin: 0;
  color: var(--white);
}
.admin-head h1 i { font-style: normal; color: var(--glow); }
.admin-head .tag {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--sky);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 3px 11px;
  text-transform: uppercase;
}

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 10px 16px;
  font-size: 14.5px;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--offwhite); }
.tab.on { color: var(--glow); border-bottom-color: var(--glow); font-weight: 600; }

.panel { display: none; }
.panel.on { display: block; }

/* ── 卡片與統計磚 ── */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card h2 {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--white);
  font-weight: 700;
}
.card .sub { margin: 0 0 16px; font-size: 13px; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 14px 16px;
}
.tile b { display: block; font-family: var(--font-en); font-size: 25px; font-weight: 800; color: var(--white); line-height: 1.2; }
.tile span { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.tile.accent b { color: var(--glow); }

/* ── 表格 ── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--sky); font-weight: 600; font-size: 12px; text-transform: none; }
tbody tr:hover { background: rgba(59, 169, 240, 0.05); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 260px; }

.pill {
  display: inline-block;
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  font-size: 11.5px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.pill.on { color: var(--glow); border-color: rgba(59, 169, 240, 0.5); }
.pill.off { color: var(--sky); opacity: .6; }
/* 到期警告也是藍的——品牌無暖色，用發光度而不是紅色來表示要注意 */
.pill.warn { color: var(--glow); border-color: var(--glow); background: rgba(59, 169, 240, 0.14); font-weight: 600; }

/* ── 按鈕與表單 ── */

.btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--offwhite);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13.5px;
  transition: all .15s;
}
.btn:hover:not(:disabled) { border-color: var(--glow); color: var(--glow); }
.btn.primary { background: var(--glow); border-color: var(--glow); color: #00172f; font-weight: 700; }
.btn.primary:hover:not(:disabled) { color: #00172f; filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .45; }

.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select {
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--offwhite);
  padding: 8px 11px;
  font-family: inherit;
  font-size: 14px;
  min-width: 130px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--glow); }
.field.grow { flex: 1; min-width: 220px; }
.field.grow input { width: 100%; }

/* ── 訊息 ── */

.msgbar {
  border-radius: var(--radius-card);
  padding: 11px 15px;
  margin-bottom: 16px;
  font-size: 13.5px;
  border: 1px solid rgba(59, 169, 240, 0.32);
  border-left: 3px solid var(--glow);
  background: rgba(59, 169, 240, 0.08);
  color: var(--offwhite);
}
.msgbar[hidden] { display: none; }
.msgbar b { color: var(--glow); }
.msgbar ul { margin: 6px 0 0; padding-left: 20px; }

/* ── 到期提醒（登入時自動跳）── */

.remind { border-left-color: var(--glow); }
.remind .who { color: var(--white); font-weight: 600; }
.remind .actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ── 長條圖：純 CSS，不引圖表套件 ── */

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 74px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-row .label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: rgba(143, 176, 214, 0.1); border-radius: var(--radius-pill); height: 15px; overflow: hidden; }
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--glow));
  border-radius: var(--radius-pill);
  min-width: 2px;
}
.bar-row .val { text-align: right; color: var(--sky); font-variant-numeric: tabular-nums; }

/* ── 明細抽屜 ── */

.detail { margin-top: 16px; }
.qitem {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 13.5px;
}
.qitem .q { color: var(--white); font-weight: 600; margin-bottom: 5px; }
.qitem .meta { color: var(--muted); font-size: 11.5px; margin-bottom: 6px; }
.qitem .a { color: var(--offwhite); white-space: pre-wrap; max-height: 150px; overflow: auto; }

.empty-note { color: var(--muted); font-size: 13.5px; padding: 10px 0; }

@media (max-width: 720px) {
  #admin { padding: 0 14px 40px; }
  .tabs { overflow-x: auto; }
  .bar-row { grid-template-columns: 76px 1fr 62px; }
}
