/* ==========================================================================
   大漢白金分會 幹部工作台 — 樣式表 (DESIGN.md 規範 & CHU-1227)
   ========================================================================== */

:root {
  /* 品牌色票 (DESIGN.md 1) */
  --bg-page: #F3F4F7;         /* 白金灰底色 */
  --bg-surface: #FFFFFF;      /* 卡片、面板 */
  --bg-surface-subtle: #F8F9FA;
  --text-primary: #1E2333;    /* 墨色主要文字 */
  --text-secondary: #5B6275;  /* 次要文字、說明 */
  --text-muted: #8A92A6;
  --primary-indigo: #26346B;  /* 深靛藍: 主要按鈕、側欄、選取 */
  --primary-hover: #1D2852;
  --primary-light: #EEF2FC;
  --accent-gold: #B8925A;     /* 香檳金: 點綴、細線、重點 */
  --accent-gold-light: #F7F3EC;
  --border-color: #E1E4EB;    /* 分隔線 */
  --border-subtle: #ECEEF2;

  /* 紅綠燈燈號色 */
  --light-green: #2E9E6B;
  --light-green-bg: #EAF7F0;
  --light-yellow: #D99A00;
  --light-yellow-bg: #FDF7EA;
  --light-red: #D64545;
  --light-red-bg: #FDEEEE;
  --light-black: #2B2D33;
  --light-black-bg: #EAEBED;

  /* 出缺席狀態色 */
  --status-p: #2E9E6B; /* 出席 */
  --status-l: #D99A00; /* 遲到 */
  --status-s: #3B82F6; /* 代理出席 */
  --status-a: #D64545; /* 缺席 */
  --status-m: #8B5CF6; /* 醫療/請假 */

  /* 幾何與排版 */
  --radius-card: 12px;
  --radius-sm: 8px;
  --radius-pill: 9999px;
  --shadow-sm: 0 1px 2px rgba(20, 25, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 25, 40, 0.05);
  --shadow-lg: 0 8px 30px rgba(20, 25, 40, 0.12);
  --font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  --sidebar-width: 232px;
  --topbar-height: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #12151E;
    --bg-surface: #1B2030;
    --bg-surface-subtle: #232A3E;
    --text-primary: #E8EAF0;
    --text-secondary: #9AA2B6;
    --text-muted: #6B748A;
    --border-color: #2E354B;
    --border-subtle: #242A3D;
    --primary-light: #212948;
    --accent-gold-light: #2E2920;

    --light-green-bg: #153325;
    --light-yellow-bg: #352B13;
    --light-red-bg: #3A1B1B;
    --light-black: #4E5466;
    --light-black-bg: #222634;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.45);
  }
}

/* 基礎重設 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-family);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 數字一律 tabular-nums (DESIGN.md 1) */
span, div, p, td, th, input, select, button {
  font-variant-numeric: tabular-nums;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ==========================================================================
   版面架構 (桌機 ≥ 960px 固定側欄 / 手機 < 960px 底部導覽)
   ========================================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* 側邊欄 (桌機) */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background-color: var(--primary-indigo);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px 20px;
}

.brand-crest {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.crest-svg {
  width: 28px;
  height: 28px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #FFFFFF;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.65);
}

.brand-divider {
  height: 1.5px;
  background: linear-gradient(90deg, var(--accent-gold) 0%, rgba(184, 146, 90, 0.2) 100%);
  margin: 0 20px 16px 20px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 180ms ease;
  min-height: 44px;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
}

.nav-item.active {
  background-color: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent-gold);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-text {
  flex: 1;
}

/* 主要包裝區 */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
}

/* 頂部列 */
.topbar {
  height: var(--topbar-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
  flex-wrap: nowrap;
}

.topbar-row-primary {
  display: contents;
}

.topbar-row-secondary {
  display: contents;
}

.topbar-left {
  order: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.mobile-brand {
  display: none;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-selector-wrap {
  order: 2;
  display: flex;
  align-items: center;
}

.batch-selector-wrap {
  order: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.topbar-auth {
  order: 4;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.batch-select-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.select-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.batch-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 32px 7px 12px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  min-height: 38px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.batch-select:focus {
  outline: none;
  border-color: var(--primary-indigo);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.select-chevron {
  position: absolute;
  right: 10px;
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  pointer-events: none;
}

.badge-alert {
  padding: 4px 10px;
  background-color: #FEF3C7;
  color: #92400E;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.privacy-icon {
  width: 14px;
  height: 14px;
  color: var(--accent-gold);
}

/* 內容區 */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.view {
  display: block;
}

.view.hidden {
  display: none !important;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   通用按鈕與表單元件
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 160ms ease;
  min-height: 40px;
  white-space: nowrap;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.82rem;
  min-height: 32px;
}

.btn-primary {
  background-color: var(--primary-indigo);
  color: #FFFFFF;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-subtle);
  border-color: var(--text-secondary);
}

.btn-gold {
  background-color: var(--accent-gold);
  color: #FFFFFF;
}

.btn-gold:hover {
  background-color: #A37E48;
}

.btn-danger {
  background-color: var(--light-red);
  color: #FFFFFF;
}

.btn-danger:hover {
  background-color: #B83232;
}

.input-text, .input-number, .input-date, .input-time, .select-control {
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.9rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  min-height: 40px;
}

.input-text:focus, .input-number:focus, .input-date:focus, .input-time:focus, .select-control:focus {
  outline: none;
  border-color: var(--primary-indigo);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.input-textarea {
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.88rem;
  font-family: monospace, var(--font-family);
  resize: vertical;
  line-height: 1.45;
  width: 100%;
  min-height: 140px;
}

.input-textarea:focus {
  outline: none;
  border-color: var(--primary-indigo);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* 卡片容器 */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   第 1 頁: 本週總覽 (Overview)
   ========================================================================== */

/* 空狀態 */
.empty-state-box {
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-card);
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--accent-gold);
}

.empty-state-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-state-desc {
  max-width: 480px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.empty-state-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

/* 6 個迷你指標卡 (第一列) */
.overview-stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 1200px) {
  .overview-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .overview-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .overview-stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.mini-stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  position: relative;
  overflow: hidden;
  min-width: 0;
  width: 100%;
}

.mini-stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.mini-stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.badge-change {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
}

.badge-change.positive {
  background-color: var(--light-green-bg);
  color: var(--light-green);
}

.badge-change.negative {
  background-color: var(--light-red-bg);
  color: var(--light-red);
}

.badge-change.neutral {
  background-color: var(--bg-surface-subtle);
  color: var(--text-muted);
}

.mini-stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.mini-sparkline-wrap {
  height: 32px;
  width: 100%;
}

.sparkline-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* 第二列: 出席狀態 (左) + 紅綠燈分布 (右) */
.overview-row-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 840px) {
  .overview-row-two {
    grid-template-columns: 1fr;
  }
}

.stacked-bar-container {
  display: flex;
  height: 14px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background-color: var(--border-subtle);
  margin: 14px 0 16px 0;
}

.bar-segment {
  height: 100%;
  transition: width 200ms ease;
}

.bar-segment-p { background-color: var(--status-p); }
.bar-segment-l { background-color: var(--status-l); }
.bar-segment-s { background-color: var(--status-s); }
.bar-segment-a { background-color: var(--status-a); }
.bar-segment-m { background-color: var(--status-m); }

.bar-segment-green  { background-color: var(--light-green); }
.bar-segment-yellow { background-color: var(--light-yellow); }
.bar-segment-red    { background-color: var(--light-red); }
.bar-segment-black  { background-color: var(--light-black); }

.stacked-legend-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.legend-chip-btn {
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  transition: all 150ms ease;
}

.legend-chip-btn:hover {
  border-color: var(--primary-indigo);
  background-color: var(--primary-light);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* 第三列: 需要關心清單 */
.care-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

@media (max-width: 640px) {
  .care-list-grid {
    grid-template-columns: 1fr;
  }
}

.care-item-card {
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: border-color 150ms ease;
  min-width: 0;
}

@media (max-width: 480px) {
  .care-item-card {
    flex-wrap: wrap;
    gap: 8px;
  }
}

.care-item-card:hover {
  border-color: var(--accent-gold);
}

.care-member-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary-indigo);
  cursor: pointer;
}

.care-member-name:hover {
  text-decoration: underline;
}

.care-tag-badge {
  font-size: 0.76rem;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.care-tag-absent {
  background-color: var(--light-red-bg);
  color: var(--light-red);
}

.care-tag-light {
  background-color: var(--light-yellow-bg);
  color: var(--light-yellow);
}

.care-tag-forecast {
  background-color: #FEF3C7;
  color: #B45309;
}

.care-empty-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: 12px 0;
}

/* 第四列: 本週例會摘要 (8a) */
.summary-box {
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: monospace, var(--font-family);
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  user-select: text;
  word-break: break-word;
}

/* ==========================================================================
   第 2 頁: 例會資料登錄 (Entry Wizard)
   ========================================================================== */

.stepper-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 0 12px;
  position: relative;
}

@media (max-width: 480px) {
  .stepper-header {
    padding: 0;
    gap: 2px;
  }
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

@media (max-width: 480px) {
  .stepper-step {
    flex-direction: column;
    gap: 4px;
    font-size: 0.72rem;
    text-align: center;
    white-space: nowrap;
  }
}

.stepper-step.active {
  color: var(--primary-indigo);
}

.stepper-step.completed {
  color: var(--light-green);
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-surface-subtle);
  border: 2px solid var(--border-color);
  font-size: 0.85rem;
}

@media (max-width: 480px) {
  .step-num {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }
}

.stepper-step.active .step-num {
  background-color: var(--primary-indigo);
  border-color: var(--primary-indigo);
  color: #FFFFFF;
}

.stepper-step.completed .step-num {
  background-color: var(--light-green);
  border-color: var(--light-green);
  color: #FFFFFF;
}

.stepper-line {
  flex: 1;
  height: 2px;
  background-color: var(--border-color);
  margin: 0 12px;
}

@media (max-width: 480px) {
  .stepper-line {
    margin: 0 2px 18px 2px;
    height: 2px;
    min-width: 6px;
  }
}

.wizard-panel {
  display: none;
}

.wizard-panel.active {
  display: block;
}

.wizard-form-group {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wizard-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.wizard-help {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.batch-code-badge {
  display: inline-block;
  padding: 6px 14px;
  background-color: var(--primary-light);
  color: var(--primary-indigo);
  font-weight: 700;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
}

.warning-callout {
  background-color: #FFFBEB;
  border-left: 4px solid var(--light-yellow);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: #92400E;
  margin-bottom: 16px;
}

.date-mismatch-warning {
  background-color: #FEF3C7;
  border-left: 4px solid var(--light-yellow);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  color: #92400E;
}

.badge-retained {
  font-size: 0.75rem;
  color: var(--accent-gold);
  font-weight: 600;
  margin-left: 4px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin: 16px 0;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* 水平捲動提示滾動條 (SPEC R3-3: 且該容器必須有可見的捲動提示) */
.table-responsive::-webkit-scrollbar {
  height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
  background: var(--bg-surface-subtle);
}
.table-responsive::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
  white-space: nowrap;
}

.data-table th {
  background-color: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.data-table tr:hover td {
  background-color: rgba(38, 52, 107, 0.02);
}

.table-input {
  width: 100%;
  min-width: 60px;
  max-width: 100px;
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.85rem;
}

.table-select {
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.85rem;
}

.wizard-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* ==========================================================================
   第 3 頁: 統計比較 (Compare)
   ========================================================================== */

.compare-period-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  margin-bottom: 20px;
}

.period-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* DESIGN.md 3 統計比較指標卡樣式:
   「淺色表面 + 左側香檳金細條, 大數字 + 下方小字前期數值 + 變化徽章(不要深色標題塊)」 */
.compare-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 480px) {
  .compare-cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.compare-stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-gold); /* 左側香檳金細條 */
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.compare-stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.compare-stat-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.compare-stat-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   第 4 頁: 表現排行 (Leaders)
   ========================================================================== */

.leaders-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.segmented-control {
  display: inline-flex;
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

@media (max-width: 640px) {
  .segmented-control {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
  }
}

.segment-btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 140ms ease;
}

@media (max-width: 640px) {
  .segment-btn {
    flex: 1 1 auto;
    min-width: fit-content;
    padding: 6px 8px;
    font-size: 0.8rem;
    text-align: center;
    white-space: nowrap;
  }
}

.segment-btn:hover {
  color: var(--text-primary);
}

.segment-btn.active {
  background-color: var(--primary-indigo);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* 前三名頒獎台 (Podium) */
.podium-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  margin: 32px 0 28px 0;
  padding: 0 12px;
}

.podium-card {
  flex: 1;
  max-width: 260px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 20px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: transform 180ms ease;
}

.podium-card:hover {
  transform: translateY(-2px);
}

.podium-first {
  border-top: 4px solid var(--accent-gold);
  border-color: rgba(184, 146, 90, 0.4);
  padding-top: 28px;
  padding-bottom: 28px;
  order: 2;
  box-shadow: 0 4px 20px rgba(184, 146, 90, 0.15);
}

.podium-second {
  border-top: 4px solid #A8B2C1; /* 銀色細邊 */
  order: 1;
}

.podium-third {
  border-top: 4px solid #CD7F32; /* 銅色細邊 */
  order: 3;
}

.podium-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.podium-first .podium-badge {
  background-color: var(--accent-gold);
  color: #FFFFFF;
}

.podium-second .podium-badge {
  background-color: #A8B2C1;
  color: #FFFFFF;
}

.podium-third .podium-badge {
  background-color: #CD7F32;
  color: #FFFFFF;
}

.podium-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-indigo);
  margin-bottom: 4px;
  cursor: pointer;
}

.podium-name:hover {
  text-decoration: underline;
}

.podium-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* 排行其餘名次清單 */
.leaders-list {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.leader-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 140ms ease;
}

.leader-row:last-child {
  border-bottom: none;
}

.leader-row:hover {
  background-color: var(--bg-surface-subtle);
}

.leader-rank {
  width: 32px;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.leader-name {
  flex: 1;
  font-weight: 600;
  color: var(--primary-indigo);
  cursor: pointer;
}

.leader-name:hover {
  text-decoration: underline;
}

.leader-val {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
}

/* ==========================================================================
   第 5 頁: 紅綠燈 (Traffic Light & 預測徽章 CHU-1227)
   ========================================================================== */

.lights-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.chip-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 140ms ease;
}

.filter-chip:hover {
  border-color: var(--text-secondary);
}

.filter-chip.active {
  background-color: var(--primary-indigo);
  color: #FFFFFF;
  border-color: var(--primary-indigo);
}

.chip-count {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.9;
}

/* 預測小徽章 (CHU-1227 3) */
.badge-forecast {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.badge-forecast-down {
  background-color: var(--light-red-bg);
  color: var(--light-red);
}

.badge-forecast-up {
  background-color: var(--light-green-bg);
  color: var(--light-green);
}

.badge-forecast-same {
  background-color: var(--bg-surface-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* 會員卡片格線 (DESIGN.md 3: 卡片左邊緣 6px 燈號色條、姓名、總分、六項指標迷你橫條) */
.lights-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

@media (max-width: 640px) {
  .lights-card-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.member-light-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
  min-width: 0;
  width: 100%;
}

.member-light-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* 左邊緣 6px 燈號色條 */
.member-light-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 6px;
}

.member-light-card.light-green::before  { background-color: var(--light-green); }
.member-light-card.light-yellow::before { background-color: var(--light-yellow); }
.member-light-card.light-red::before    { background-color: var(--light-red); }
.member-light-card.light-black::before  { background-color: var(--light-black); }

.light-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 6px;
}

.light-member-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.light-score-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.92rem;
}

.light-green .light-score-pill  { background-color: var(--light-green-bg); color: var(--light-green); }
.light-yellow .light-score-pill { background-color: var(--light-yellow-bg); color: var(--light-yellow); }
.light-red .light-score-pill    { background-color: var(--light-red-bg); color: var(--light-red); }
.light-black .light-score-pill  { background-color: var(--light-black-bg); color: var(--light-black); }

/* 六項指標迷你橫條 */
.light-metrics-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  padding-left: 6px;
}

.metric-bar-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.metric-bar-track {
  height: 6px;
  background-color: var(--border-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  background-color: var(--primary-indigo);
  border-radius: var(--radius-pill);
}

/* ==========================================================================
   第 6 頁: 會員名冊 (Members)
   ========================================================================== */

.alias-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.alias-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-primary);
}

.alias-tag-del {
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1;
}

.alias-tag-del:hover {
  color: var(--light-red);
}

.badge-status-active {
  background-color: var(--light-green-bg);
  color: var(--light-green);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 600;
}

.badge-status-inactive {
  background-color: var(--bg-surface-subtle);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 600;
}

/* ==========================================================================
   第 7 頁: 設定與備份 (Settings)
   ========================================================================== */

.tier-edit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0;
  white-space: nowrap;
}

.tier-edit-table th, .tier-edit-table td {
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.tier-edit-table th {
  background-color: var(--bg-surface-subtle);
  font-weight: 600;
}

/* ==========================================================================
   會員個人頁抽屜 (8b: 桌機右側寬抽屜、手機全螢幕 & CHU-1227 預測區塊)
   ========================================================================== */

.drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(18, 21, 30, 0.55);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  justify-content: flex-end;
  opacity: 1;
  transition: opacity 180ms ease;
}

.drawer-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.drawer-panel {
  width: 520px;
  max-width: 100%;
  height: 100%;
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(0);
  transition: transform 220ms ease;
}

.drawer-backdrop.hidden .drawer-panel {
  transform: translateX(100%);
}

.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.drawer-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.drawer-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.drawer-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background-color 150ms ease;
}

.drawer-close:hover {
  background-color: var(--bg-surface-subtle);
  color: var(--text-primary);
}

.drawer-close svg {
  width: 20px;
  height: 20px;
}

.drawer-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* 4 週後預測區塊 (CHU-1227 3) */
.forecast-card-section {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background-color: var(--bg-surface-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* 26 梯次出缺席點陣 (SPEC 8b) */
.dot-matrix-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dot-matrix-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 6px;
}

.dot-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  transition: transform 140ms ease;
}

.dot-cell:hover {
  transform: scale(1.2);
  z-index: 5;
}

.dot-p { background-color: var(--status-p); }
.dot-l { background-color: var(--status-l); }
.dot-s { background-color: var(--status-s); }
.dot-a { background-color: var(--status-a); }
.dot-m { background-color: var(--status-m); }
.dot-none { background-color: var(--border-subtle); }

.dot-matrix-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  margin-top: 4px;
}

/* 距離下一級還差多少提示卡 (SPEC 8b) */
.gap-callout {
  background-color: var(--accent-gold-light);
  border-left: 3px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.82rem;
  color: var(--text-primary);
  margin-top: 6px;
}

/* ==========================================================================
   手機底部導覽列與選單 (< 960px)
   ========================================================================== */

.mobile-bottom-nav {
  display: none;
}

.mobile-sheet-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(18, 21, 30, 0.5);
  z-index: 150;
  display: flex;
  align-items: flex-end;
}

.mobile-sheet {
  width: 100%;
  background-color: var(--bg-surface);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  box-shadow: var(--shadow-lg);
}

.mobile-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.mobile-sheet-title {
  font-weight: 700;
  font-size: 1rem;
}

.mobile-sheet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  background-color: var(--bg-surface-subtle);
}

.sheet-icon {
  width: 20px;
  height: 20px;
  color: var(--primary-indigo);
}

/* ==========================================================================
   Toast 訊息提示
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background-color: var(--text-primary);
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 180ms ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   響應式規則 (手機 < 960px)
   ========================================================================== */

@media (max-width: 959px) {
  .sidebar {
    display: none;
  }

  .main-wrapper {
    margin-left: 0;
    width: 100%;
    min-width: 0;
    padding-bottom: 72px; /* 留出底部導覽列空間 (≥ 58px, SPEC R3-3) */
  }

  .mobile-brand {
    display: none !important;
  }

  /* 手機版頂部列兩排 (SPEC R3-1) */
  .topbar {
    height: auto;
    min-height: 56px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: sticky;
    top: 0;
    z-index: 90;
    overflow: visible;
  }

  .topbar-row-primary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
    gap: 8px;
  }

  .topbar-row-secondary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
    gap: 8px;
  }

  .topbar-left {
    order: unset;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }

  .topbar-auth {
    order: unset;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  .chapter-selector-wrap {
    order: unset;
    display: flex;
    align-items: center;
    min-width: 0;
    flex-shrink: 1;
  }

  .batch-selector-wrap {
    order: unset;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
  }

  .page-title {
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
  }

  .batch-select-label {
    display: none !important;
  }

  .batch-select {
    padding: 5px 22px 5px 8px;
    font-size: 0.8rem;
    min-height: 34px;
    max-width: 140px;
    white-space: nowrap;
  }

  .select-chevron {
    right: 6px;
    width: 14px;
    height: 14px;
  }

  .privacy-badge {
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 28px;
  }

  .privacy-text {
    display: none !important;
  }

  .privacy-icon {
    width: 15px;
    height: 15px;
  }

  .main-content {
    padding: 12px;
    min-width: 0;
  }

  .card {
    padding: 14px 12px;
    margin-bottom: 14px;
  }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    z-index: 120;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
    transition: color 140ms ease;
  }

  .mobile-nav-item.active {
    color: var(--primary-indigo);
    font-weight: 700;
  }

  .mobile-nav-icon {
    width: 20px;
    height: 20px;
  }

  .drawer-panel {
    width: 100%;
  }

  .podium-container {
    flex-direction: column;
    align-items: stretch;
  }

  .podium-card {
    max-width: 100%;
    width: 100%;
  }

  .podium-first {
    order: 1;
  }
  .podium-second {
    order: 2;
  }
  .podium-third {
    order: 3;
  }

  .migrate-banner {
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  .chapter-name-badge, .badge-demo {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 3px 8px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .user-name-text {
    display: none !important;
  }

  .btn-logout-link {
    padding: 2px 4px;
    font-size: 0.75rem;
  }
}

/* ==========================================================================
   舊資料搬家提示條 (SPEC-CHU-1228 5)
   ========================================================================== */

.migrate-banner {
  background-color: var(--primary-light);
  border-bottom: 1.5px solid var(--accent-gold);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 95;
  flex-wrap: wrap;
}

.migrate-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.migrate-icon {
  width: 20px;
  height: 20px;
  color: var(--accent-gold);
  flex-shrink: 0;
}

.migrate-banner-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ==========================================================================
   頂部列擴充: 分會、示範模式、使用者資訊 (SPEC-CHU-1228 3)
   ========================================================================== */

.chapter-selector-wrap {
  display: flex;
  align-items: center;
}

.chapter-name-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background-color: var(--primary-light);
  color: var(--primary-indigo);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.demo-badge-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.badge-demo {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  background-color: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.user-profile-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.user-info-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar-img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--accent-gold);
  flex-shrink: 0;
}

.user-avatar-placeholder {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-indigo);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1.5px solid var(--accent-gold);
  flex-shrink: 0;
}

.user-name-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.btn-logout-link {
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 150ms ease;
  white-space: nowrap;
  background: none;
  border: 1px solid transparent;
}

.btn-logout-link:hover {
  color: var(--light-red);
  background-color: var(--light-red-bg);
  border-color: var(--light-red-bg);
}

button:disabled, .btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ==========================================================================
   全螢幕認證畫面 (登入 / 無分會) (SPEC-CHU-1228 2)
   ========================================================================== */

.app-fullscreen-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-page);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  padding: 44px 32px;
  max-width: 440px;
  width: 100%;
  text-align: center;
}

.login-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.5;
}

.login-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-line {
  background-color: #06C755;
  color: #FFFFFF !important;
  font-weight: 700;
  border: none;
  min-height: 44px;
  font-size: 0.95rem;
  box-shadow: 0 2px 6px rgba(6, 199, 85, 0.25);
}

.btn-line:hover {
  background-color: #05B34C;
}

.line-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ==========================================================================
   彈窗樣式 (邀請卡等)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(18, 21, 30, 0.65);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  max-width: 460px;
  width: 100%;
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body {
  padding: 24px 20px;
}

.invite-card-inner {
  text-align: center;
}

.invite-chapter-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-indigo);
  margin-bottom: 6px;
}

.invite-role-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  background-color: var(--accent-gold-light);
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold);
  margin-bottom: 16px;
}

/* ==========================================================================
   設定頁: 成員與邀請區塊 (SPEC-CHU-1228 6)
   ========================================================================== */

.action-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  background-color: var(--primary-light);
  color: var(--primary-indigo);
}

.invite-link-copy-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0 6px;
}

.invite-link-input {
  flex: 1;
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--text-primary);
  min-height: 36px;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-cell-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.user-cell-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--primary-indigo);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ==========================================================================
   第 2 階段第二輪新增樣式 (SPEC-CHU-1228-UI-R2)
   ========================================================================== */

/* A1: 登入/無分會畫面外露導覽修正 */
body.auth-mode .sidebar,
body.auth-mode .topbar,
body.auth-mode .mobile-bottom-nav,
body.auth-mode .batch-selector-wrap,
body.auth-mode .migrate-banner {
  display: none !important;
}

body.auth-mode .main-wrapper {
  margin-left: 0 !important;
  width: 100% !important;
  padding-bottom: 0 !important;
}

/* 確保導覽項目 hidden 一律生效 */
.mobile-nav-item.hidden,
.sidebar .nav-item.hidden,
.sheet-item.hidden {
  display: none !important;
}

/* A3: 期間累計報表說明卡與燈號晶片 */
.period-notice-card {
  background-color: var(--primary-light);
  border: 1.5px solid var(--primary-indigo);
  border-radius: var(--radius-card);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.period-notice-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-indigo);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-notice-desc {
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.6;
}

.period-lights-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 16px 0;
}

.light-count-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
}

.light-count-chip.green {
  background-color: var(--light-green-bg);
  color: var(--light-green);
  border: 1px solid var(--light-green);
}

.light-count-chip.yellow {
  background-color: var(--light-yellow-bg);
  color: var(--light-yellow);
  border: 1px solid var(--light-yellow);
}

.light-count-chip.red {
  background-color: var(--light-red-bg);
  color: var(--light-red);
  border: 1px solid var(--light-red);
}

.light-count-chip.black {
  background-color: var(--light-black-bg);
  color: var(--light-black);
  border: 1px solid var(--light-black);
}

/* A6: 規則編輯級距單位包裝 */
.tier-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tier-unit {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* B1 & B2: Zoom 分頁與原始資料明細 */
.zoom-tabs-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
  background-color: var(--bg-surface-subtle);
  padding: 4px;
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}

.zoom-tab-btn {
  flex: 1;
  min-width: 110px;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 6px;
  color: var(--text-secondary);
  text-align: center;
  transition: all 140ms ease;
  background: none;
  border: none;
  cursor: pointer;
}

@media (max-width: 480px) {
  .zoom-tab-btn {
    min-width: 90px;
    padding: 6px 8px;
    font-size: 0.8rem;
  }
}

.zoom-tab-btn:hover {
  color: var(--text-primary);
  background-color: rgba(0, 0, 0, 0.03);
}

.zoom-tab-btn.active {
  background-color: var(--bg-surface);
  color: var(--primary-indigo);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.row-unmatched {
  background-color: #FEF9E7 !important;
}

@media (prefers-color-scheme: dark) {
  .row-unmatched {
    background-color: #352B13 !important;
  }
}

/* B3: 來賓清單小卡 */
.guest-summary-card {
  background-color: var(--accent-gold-light);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.guest-summary-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.guest-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.guest-tag {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  color: var(--text-primary);
}

/* B4-3: 登錄步驟說明小字 */
.wizard-step-purpose {
  font-size: 0.86rem;
  color: var(--text-secondary);
  margin-top: -8px;
  margin-bottom: 18px;
  line-height: 1.45;
}

/* B4-4: 頁面說明 ? 按鈕與浮動說明卡 */
.btn-help-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-gold);
  color: var(--accent-gold);
  background: none;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 8px;
  transition: all 140ms ease;
  line-height: 1;
}

.btn-help-circle:hover {
  background-color: var(--accent-gold-light);
  color: var(--accent-gold);
}

.page-help-popover {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 12px 16px;
  margin: 12px 28px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  animation: toastIn 180ms ease forwards;
}

@media (max-width: 959px) {
  .page-help-popover {
    margin: 8px 12px 0;
  }
}

.page-help-content {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-primary);
  flex: 1;
}

.btn-close-help {
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  background: none;
  border: none;
}

.btn-close-help:hover {
  color: var(--text-primary);
}

/* B4-1 & B4-2: 教學導覽彈窗 */
.tour-modal-card {
  max-width: 520px;
}

.tour-stepper-indicator {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.tour-dot {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background-color: var(--border-color);
  transition: background-color 180ms ease;
}

.tour-dot.active {
  background-color: var(--primary-indigo);
}

.tour-dot.completed {
  background-color: var(--accent-gold);
}

.tour-step-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 700;
  background-color: var(--primary-light);
  color: var(--primary-indigo);
  margin-bottom: 12px;
}

.tour-step-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.tour-step-desc {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.tour-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-surface-subtle);
}

.tour-nav-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

