/* ── CSS Custom Properties ────────────────────────────────────────────────── */
:root {
  --c-primary:       #2d6a4f;
  --c-primary-light: #52b788;
  --c-primary-dark:  #1a4a32;
  --c-bg:            #f4f7f4;
  --c-surface:       #ffffff;
  --c-text:          #222222;
  --c-text-muted:    #666666;
  --c-border:        #d1d5db;
  --c-accent:        #e9f5ee;
}

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "Helvetica Neue", Arial, "PingFang TC", "Microsoft JhengHei", sans-serif;
       background: #f4f7f4; color: #222; font-size: 15px; }
a { color: #2d7a4f; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header { background: var(--c-primary); color: #fff; padding: 0 16px; position: relative; z-index: 600; }
.header-inner { max-width: 960px; margin: 0 auto; display: flex;
                align-items: center; justify-content: space-between; height: 52px; }
.logo { font-size: 17px; font-weight: bold; }
.site-header nav a { color: #cfe8d9; margin-left: 16px; font-size: 14px; }
.site-header nav a:hover { color: #fff; text-decoration: none; }

/* ── Container ────────────────────────────────────────────────────────────── */
.container { max-width: 960px; margin: 0 auto; padding: 20px 16px 60px; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; }
.alert-success { background: #d4edda; color: #155724; }
.alert-error   { background: #f8d7da; color: #721c24; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block; padding: 8px 16px; border-radius: 6px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: none; background: #e0e0e0; color: #333; text-align: center;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-blue    { background: #2563eb; color: #fff; }
.btn-green   { background: #16a34a; color: #fff; }
.btn-red     { background: #dc2626; color: #fff; }
.btn-upload  { background: var(--c-primary-light); color: #fff; padding: 10px 14px; font-size: 14px;
               display: block; width: 100%; margin-top: 8px; border-radius: 8px; }
.btn-block   { display: block; width: 100%; padding: 12px; font-size: 16px; margin-top: 14px; }
.btn-sm      { padding: 5px 10px; font-size: 12px; }

/* ── Page titles ──────────────────────────────────────────────────────────── */
.page-title { font-size: 20px; font-weight: bold; margin-bottom: 4px; }
.subtitle   { color: #666; font-size: 14px; margin-bottom: 16px; }

/* ── Plan cards (public board) ────────────────────────────────────────────── */
.plan-card {
  background: #fff; border-radius: 10px; padding: 16px;
  margin-bottom: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.08);
  border-left: 4px solid #b0b0b0;
}
.plan-card.status-announced   { border-left-color: #94a3b8; }
.plan-card.status-in_progress { border-left-color: #f59e0b; }
.plan-card.status-submitted   { border-left-color: #3b82f6; }
.plan-card.status-confirmed   { border-left-color: #16a34a; }

.plan-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.plan-title  { font-size: 17px; font-weight: bold; }
.plan-date   { font-size: 13px; color: #666; }
.plan-meta   { font-size: 13px; color: #555; display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.plan-notes  { font-size: 13px; color: #888; margin-bottom: 8px; }
.confirmed-msg { text-align: center; color: #16a34a; font-weight: 600; padding: 8px; }

/* ── Stage chips ──────────────────────────────────────────────────────────── */
.progress-row, .progress-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.stage-chip {
  font-size: 12px; padding: 3px 10px; border-radius: 20px;
  background: #e5e7eb; color: #555;
}
.stage-chip.partial { background: #fef3c7; color: #92400e; }
.stage-chip.done    { background: #d1fae5; color: #065f46; }

/* ── Status badges ────────────────────────────────────────────────────────── */
.status-badge { font-size: 12px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.status-badge.status-announced   { background: #e2e8f0; color: #475569; }
.status-badge.status-in_progress { background: #fef3c7; color: #92400e; }
.status-badge.status-submitted   { background: #dbeafe; color: #1e40af; }
.status-badge.status-confirmed   { background: #dcfce7; color: #15803d; }

/* ── Upload page ──────────────────────────────────────────────────────────── */
.upload-header { margin-bottom: 16px; }
.upload-header h2 { font-size: 20px; margin: 6px 0 4px; }
.back-link { font-size: 13px; color: #2d7a4f; }

.worker-select-bar {
  display: flex; align-items: center; gap: 10px;
  background: #fff; padding: 12px 16px; border-radius: 8px;
  margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.worker-select-bar select {
  flex: 1; padding: 8px 10px; border-radius: 6px;
  border: 1px solid #d1d5db; font-size: 15px;
}

.progress-summary { padding: 10px 0; }

.group-card {
  background: #fff; border-radius: 10px; padding: 14px 14px 18px;
  margin-bottom: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.group-title { font-weight: bold; font-size: 15px; margin-bottom: 12px;
               color: var(--c-primary); border-bottom: 1px solid #e5e7eb; padding-bottom: 6px; }

.stage-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stage-slot { display: flex; flex-direction: column; align-items: center; }
.stage-label { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }

.thumb-wrap, .thumb-empty {
  width: 100%; aspect-ratio: 4/3; border-radius: 6px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #f1f5f9; margin-bottom: 4px;
}
.thumb-empty { border: 2px dashed #cbd5e1; color: #94a3b8; font-size: 0.8125rem; }
.thumb-img   { width: 100%; height: 100%; object-fit: cover; }
.thumb-done  { font-size: 13px; color: #16a34a; font-weight: 600; }

/* ── 共用：頁面主標題 + 螢幕閱讀器隱藏 ─────────────────────────────────────── */
.page-title {
  font-size: 22px; font-weight: 700; color: #1f2937;
  margin: 0 0 16px; padding-bottom: 8px;
  border-bottom: 2px solid var(--c-primary);
}
.sr-only {
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

/* ── Admin dashboard ──────────────────────────────────────────────────────── */
.dash-topbar { display: flex; align-items: center; justify-content: space-between;
               margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.dash-topbar h2 { font-size: 20px; }
.dash-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.dash-actions input[type=month] { padding: 6px 10px; border: 1px solid #d1d5db;
                                   border-radius: 6px; font-size: 14px; }

.table-wrap { overflow-x: auto; }
.dash-table { width: 100%; border-collapse: collapse; background: #fff;
              border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.dash-table th { background: var(--c-primary); color: #fff; padding: 10px 12px;
                 font-size: 13px; text-align: left; white-space: nowrap; }
.dash-table td { padding: 9px 12px; font-size: 13px; border-bottom: 1px solid #f1f5f9; }
.dash-table tr:last-child td { border-bottom: none; }
.dash-table tr:hover td { background: #f9fafb; }
.dash-table .center { text-align: center; }
.dash-table .cell-done    { color: #16a34a; font-weight: 700; }
.dash-table .cell-partial { color: #d97706; font-weight: 700; }
.doc-cell .btn, .action-cell .btn { margin: 2px 1px; }
.row-status-confirmed td { color: #888; }
.muted { color: #aaa; }
.empty-msg { text-align: center; padding: 40px; color: #999; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.login-wrap, .form-wrap {
  max-width: 400px; margin: 40px auto 0;
  background: #fff; border-radius: 10px; padding: 28px 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.login-wrap h2, .form-wrap h2 { margin-bottom: 20px; }
label { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; color: #374151; }
label input, label select, label textarea {
  display: block; width: 100%; margin-top: 4px;
  padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 15px; background: #fafafa;
}
label textarea { resize: vertical; }
.hint { font-size: 12px; color: #888; margin-top: 14px; text-align: center; }

/* ── Settings ─────────────────────────────────────────────────────────────── */
.settings-section { background: #fff; border-radius: 10px; padding: 20px;
                    margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.07); }
.settings-section h3 { font-size: 16px; margin-bottom: 14px;
                        color: var(--c-primary); border-bottom: 1px solid #e5e7eb; padding-bottom: 8px; }
.settings-section label { max-width: 480px; }
.inline-form { display: flex; gap: 8px; margin-bottom: 14px; }
.inline-form input { flex: 1; padding: 8px 12px; border: 1px solid #d1d5db;
                     border-radius: 6px; font-size: 14px; }
.settings-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.settings-table th { background: #f1f5f9; padding: 8px 12px; text-align: left; }
.settings-table td { padding: 8px 12px; border-top: 1px solid #f1f5f9; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .dash-table th, .dash-table td { padding: 7px 8px; font-size: 12px; }
  .plan-title { font-size: 15px; }

  /* 手機：讓儀表板表格橫向捲動，避免中文被擠成直書 */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    position: relative;
  }
  /* 提示使用者可左右滑動 */
  .table-wrap::after {
    content: '← 左右滑動檢視完整表格 →';
    display: block;
    text-align: center;
    font-size: 0.8125rem;
    color: #9ca3af;
    padding: 4px 0 6px;
  }
  .dash-table { min-width: 860px; }
  .dash-table th, .dash-table td { white-space: nowrap; }
  .dash-table td:nth-child(2) {   /* 公司欄 */
    max-width: 120px; white-space: normal; word-break: break-word;
  }
  .dash-table td:nth-child(4) {   /* 地點欄 */
    max-width: 160px; white-space: normal; word-break: break-word;
  }

  /* 工具列：手機版按鈕換行，避免整頁水平溢出 */
  .dash-topbar { flex-direction: column; align-items: stretch; }
  .dash-topbar h2 { font-size: 17px; margin-bottom: 4px; }
  .dash-actions {
    display: flex; flex-wrap: wrap;
    gap: 6px; padding-bottom: 6px;
  }
  .dash-actions .btn, .dash-actions button {
    padding: 6px 10px; font-size: 13px; white-space: nowrap;
  }
  .dash-actions input[type=month],
  .dash-actions select { font-size: 13px; padding: 5px 8px; }
}

/* ── 手機專屬（≤480px）──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  /* 上傳照片：前/中/後改成單欄，卡片清晰好按 */
  .stage-grid { grid-template-columns: 1fr; gap: 10px; }
  /* 上傳按鈕加高，符合 44px 最小點擊區 */
  .btn-upload { padding: 13px 14px; min-height: 44px; font-size: 15px; }
  /* 施工說明 hint 字不要太小 */
  .group-note-hint { font-size: 0.8rem; }
  /* sticky bar：跳至下一空格按鈕佔滿寬度 */
  .sticky-progress { flex-wrap: wrap; gap: 6px; }
  .jump-btn { margin-left: 0; flex: 1 1 100%; text-align: center; padding: 9px 14px; }
}

/* ── 小米姐激勵語（LINE 訊息風格）──────────────────────────────────────────── */
.boss-msg-wrap {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 14px; padding: 4px 0;
}
/* 左側：頭像 + 名字 */
.boss-left  { display: flex; flex-direction: column; align-items: center; gap: 4px; flex-shrink: 0; }
.boss-avatar {
  position: relative; width: 58px; height: 58px;
}
.boss-face {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 36px; line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.15));
}
.boss-emoji {
  position: absolute; bottom: -2px; right: -2px;
  font-size: 18px; line-height: 1;
  background: #fff; border-radius: 50%; padding: 1px;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
/* avatar 圓形底盤（顏色由 JS inline div 控制，::before 僅佔位） */
.boss-avatar::before {
  content: '';
  display: block; width: 58px; height: 58px; border-radius: 50%;
}
.boss-name {
  font-size: 12px; font-weight: 700; color: #555;
  white-space: nowrap;
}
/* 右側：對話氣泡 */
.boss-bubble {
  position: relative; flex: 1;
  background: #fff;
  border-radius: 0 14px 14px 14px;
  padding: 13px 16px 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.10);
  border: 1.5px solid #ffe0ea;
}
/* 氣泡左側三角（顏色跟著 --boss-border 變數） */
.boss-bubble::before {
  content: '';
  position: absolute; left: -9px; top: 14px;
  border: 5px solid transparent;
  border-right: 9px solid var(--boss-border, #ffe0ea);
}
.boss-bubble::after {
  content: '';
  position: absolute; left: -7px; top: 15px;
  border: 4px solid transparent;
  border-right: 8px solid #fff;
}
.boss-bubble-title  { font-size: 16px; font-weight: 800; color: #d63384; margin-bottom: 5px; }
.boss-bubble-body   { font-size: 14px; color: #333; line-height: 1.65; }
.boss-bubble-footer { font-size: 12px; color: #aaa; margin-top: 8px; text-align: right; }

/* ── Board toolbar ──────────────────────────────────────────────────────────── */
.board-toolbar { display: flex; justify-content: space-between; align-items: center;
                 flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.filter-form   { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-form input, .filter-form select {
  padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px;
}

/* ── PIN page ───────────────────────────────────────────────────────────────── */
.pin-page { min-height: 100vh; display: flex; align-items: center;
            justify-content: center; background: #f4f7f4; }
.pin-box  { background: #fff; border-radius: 14px; padding: 36px 28px; width: 320px;
            box-shadow: 0 4px 20px rgba(0,0,0,.12); text-align: center; }
.pin-logo { font-size: 48px; margin-bottom: 10px; }
.pin-box h2 { font-size: 16px; color: var(--c-primary); margin-bottom: 8px; }
.pin-hint  { color: #666; font-size: 14px; margin-bottom: 18px; }
.pin-input { width: 100%; padding: 12px; border: 2px solid #d1d5db; border-radius: 8px;
             font-size: 20px; text-align: center; letter-spacing: 4px;
             margin-bottom: 14px; outline: none; }
.pin-input:focus { border-color: var(--c-primary-light); }

/* ── Badge ──────────────────────────────────────────────────────────────────── */
.badge-me { font-size: 0.8rem; background: #dbeafe; color: #1e40af;
            padding: 1px 6px; border-radius: 10px; }

/* ── Today bar ──────────────────────────────────────────────────────────────── */
.today-bar {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 10px; padding: 12px 16px;
  margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.07);
  border-left: 4px solid var(--c-primary-light);
}
.today-icon { font-size: 20px; }
.today-text { font-size: 17px; font-weight: 700; color: var(--c-primary); flex: 1; }
/* 快速跳到今日工項按鈕 */
.today-jump-btn {
  margin-left: auto; flex-shrink: 0;
  background: var(--c-primary); color: #fff;
  border-radius: 20px; padding: 5px 13px;
  font-size: 13px; font-weight: 700;
  white-space: nowrap; text-decoration: none;
}
.today-jump-btn:hover { opacity: .88; text-decoration: none; }

/* ── Joke card ──────────────────────────────────────────────────────────────── */
.joke-card {
  background: linear-gradient(135deg, #fff9e6, #fff3cd);
  border-radius: 12px; padding: 14px 18px; margin-bottom: 14px;
  border-left: 4px solid #f59e0b; box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
.joke-header { font-size: 13px; font-weight: 700; color: #92400e; margin-bottom: 6px; }
.joke-title  { font-size: 15px; font-weight: 700; color: #1f2937; margin-bottom: 4px; }
.joke-body   { font-size: 14px; color: #374151; line-height: 1.6; }

/* ── Info row (weather + calendar side by side) ─────────────────────────────── */
.info-row { display: flex; gap: 12px; margin-bottom: 14px; }
.info-row > * { flex: 1; min-width: 0; }
@media (max-width: 600px) { .info-row { flex-direction: column; } }

.card-header {
  font-size: 14px; font-weight: 700; color: var(--c-primary);
  padding-bottom: 8px; margin-bottom: 10px;
  border-bottom: 1px solid #e5e7eb;
}

/* ── Weather ────────────────────────────────────────────────────────────────── */
.weather-card {
  background: linear-gradient(160deg, #e0f2fe, #f0fdf4);
  border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
.weather-days  { display: flex; gap: 8px; }
.weather-day   { flex: 1; text-align: center; background: rgba(255,255,255,.7);
                 border-radius: 10px; padding: 10px 6px; }
.today-weather { background: rgba(255,255,255,.95); box-shadow: 0 2px 6px rgba(45,106,79,.15); }
.wd-date  { font-size: 0.8125rem; color: #555; margin-bottom: 4px; }
.wd-emoji { font-size: 26px; line-height: 1.2; }
.wd-desc  { font-size: 0.8125rem; color: #374151; margin: 3px 0; }
.wd-temp  { font-size: 13px; font-weight: 700; color: #1f2937; }
.wd-rain  { font-size: 0.8125rem; color: #3b82f6; margin-top: 3px; }

/* ── Mini calendar ──────────────────────────────────────────────────────────── */
.cal-card {
  background: #fff; border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
.cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; margin-bottom: 8px;
}
.cal-nav-btn {
  background: #f1f5f9; border-radius: 6px; padding: 2px 10px;
  font-size: 16px; color: var(--c-primary); font-weight: bold;
}
.mini-cal { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-cal th { text-align: center; padding: 4px 2px; color: #666; font-size: 12px; }
.mini-cal td { text-align: center; padding: 5px 2px; border-radius: 50%;
               width: 32px; height: 32px; cursor: default; }
.mini-cal td.empty       { color: transparent; }
.mini-cal td.sun         { color: #ef4444; }
.mini-cal td.sat         { color: #3b82f6; }
.mini-cal th.sun         { color: #ef4444; }
.mini-cal th.sat         { color: #3b82f6; }
.mini-cal td.cal-today   { background: var(--c-primary) !important; color: #fff !important;
                            border-radius: 50%; font-weight: bold; }
.mini-cal td.has-plan    { background: #d1fae5; border-radius: 50%; font-weight: 600; color: #065f46; }
.mini-cal td.cal-today.has-plan { background: var(--c-primary) !important; color: #fff !important; }
.cal-legend { display: flex; gap: 12px; margin-top: 8px; font-size: 0.8125rem; color: #666; }
.leg-today  { display: flex; align-items: center; gap: 4px; }
.leg-today::before { content: ''; width: 12px; height: 12px; border-radius: 50%;
                     background: var(--c-primary); display: inline-block; }
.leg-plan   { display: flex; align-items: center; gap: 4px; }
.leg-plan::before  { content: ''; width: 12px; height: 12px; border-radius: 50%;
                     background: #d1fae5; border: 1px solid #065f46; display: inline-block; }

/* ── Tutorial section ───────────────────────────────────────────────────────── */
.tutorial-wrap {
  background: #fff; border-radius: 12px; margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07); overflow: hidden;
}
.tutorial-toggle {
  width: 100%; background: none; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; font-size: 15px; font-weight: 700; color: var(--c-primary);
}
.tutorial-toggle .arrow { font-size: 18px; transition: transform .25s; }
.tutorial-toggle.open .arrow { transform: rotate(180deg); }
.tutorial-body { display: none; padding: 0 18px 18px; }
.tutorial-body.open { display: block; }
.tutorial-steps { display: grid; gap: 10px; }
.step-card {
  display: flex; gap: 14px; align-items: flex-start;
  background: #f8fafc; border-radius: 10px; padding: 12px 14px;
}
.step-num {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
  background: var(--c-primary); color: #fff; font-weight: bold;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.step-title { font-weight: 700; font-size: 14px; margin-bottom: 3px; color: #1f2937; }
.step-desc  { font-size: 13px; color: #555; line-height: 1.5; }
.step-tip   { font-size: 12px; color: #2d7a4f; margin-top: 4px;
              background: #d1fae5; border-radius: 6px; padding: 3px 8px; display: inline-block; }

/* ── 統計儀表板 ───────────────────────────────── */
.stats-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.kpi-card.kpi-green { border-color: var(--c-primary-light); background: #f0faf4; }
.kpi-card.kpi-yellow { border-color: #f59e0b; background: #fffbeb; }
.kpi-card.kpi-blue  { border-color: #60a5fa; background: #eff6ff; }
.kpi-num { font-size: 2.2rem; font-weight: 800; color: var(--c-primary); line-height: 1; }
.kpi-green .kpi-num { color: var(--c-primary); }
.kpi-yellow .kpi-num { color: #b45309; }
.kpi-blue .kpi-num  { color: #1d4ed8; }
.kpi-label { font-size: 0.82rem; color: #6b7280; margin-top: 6px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.stats-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 18px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.stats-card-title {
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 14px;
  font-size: 0.95rem;
}
.stats-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.stats-bar-label {
  min-width: 80px;
  font-size: 0.82rem;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.stats-bar-wrap {
  flex: 1;
  background: #f3f4f6;
  border-radius: 99px;
  height: 12px;
  overflow: hidden;
}
.stats-bar {
  height: 100%;
  background: var(--c-primary-light);
  border-radius: 99px;
  transition: width 0.4s ease;
  min-width: 4px;
}
.stats-bar-green { background: var(--c-primary-light); }
.stats-bar-blue  { background: #60a5fa; }
.stats-bar-val {
  font-size: 0.8rem;
  color: #6b7280;
  min-width: 38px;
  text-align: right;
}
.status-pie-list { display: flex; flex-direction: column; gap: 12px; }
.status-pie-row  { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }

/* ── Modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 18px;
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
}
.modal-box h3 { margin: 0 0 10px; font-size: 1.1rem; }

/* ── 教學頁面 — 流程總覽 ──────────────────────── */
.tut-flow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  background: linear-gradient(135deg,#f0faf4,#e8f5e9);
  border-radius: 14px;
  padding: 18px 14px;
  margin-bottom: 18px;
}
.tut-flow-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tut-flow-icon {
  font-size: 1.9rem;
  background: #fff;
  border-radius: 50%;
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(45,106,79,0.15);
}
.tut-flow-label {
  font-size: 0.8125rem;
  color: var(--c-primary);
  font-weight: 600;
  text-align: center;
}
.tut-flow-arrow {
  font-size: 1.3rem;
  color: var(--c-primary-light);
  font-weight: 700;
  margin: 0 2px;
}

/* ── 教學頁面 — 三階段方塊 ───────────────────── */
.tut-stage-row {
  display: flex;
  gap: 8px;
  margin: 12px 0 4px;
}
.tut-stage-box {
  flex: 1;
  border-radius: 10px;
  padding: 12px 6px;
  text-align: center;
  border: 2px solid transparent;
}
.tut-stage-before { background: #eff6ff; border-color: #bfdbfe; }
.tut-stage-during { background: #fefce8; border-color: #fde68a; }
.tut-stage-after  { background: #f0fdf4; border-color: #bbf7d0; }
.tut-stage-icon   { font-size: 1.3rem; }
.tut-stage-name   { font-weight: 700; font-size: 0.85rem; margin: 4px 0 2px; }
.tut-stage-before .tut-stage-name { color: #1d4ed8; }
.tut-stage-during .tut-stage-name { color: #92400e; }
.tut-stage-after  .tut-stage-name { color: #065f46; }
.tut-stage-desc   { font-size: 0.8125rem; color: #6b7280; line-height: 1.4; }

/* ── 教學頁面 — 警告框 ───────────────────────── */
.tut-warn-box {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: #92400e;
  margin-top: 10px;
}

/* ── 教學頁面 — 常見問題 ─────────────────────── */
.tut-faq-wrap {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px 16px;
  margin-top: 18px;
}
.tut-faq-title {
  font-weight: 700;
  color: #1f2937;
  font-size: 0.95rem;
  margin-bottom: 14px;
}
.tut-faq-item {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e5e7eb;
}
.tut-faq-item:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.tut-faq-q {
  font-weight: 600;
  color: var(--c-primary);
  font-size: 0.88rem;
  margin-bottom: 4px;
}
.tut-faq-a {
  color: #4b5563;
  font-size: 0.85rem;
  line-height: 1.55;
}

/* ── 教學頁面 — 管理者分頁標籤 ──────────────── */
.tut-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 16px 0;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 16px;
}
.tut-tab {
  background: none;
  border: none;
  padding: 8px 14px;
  border-radius: 8px 8px 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  margin-bottom: -2px;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tut-tab:hover { color: var(--c-primary); background: #f0faf4; }
.tut-tab.active {
  color: var(--c-primary);
  border-bottom: 2px solid var(--c-primary);
  background: #f0faf4;
}
.tut-tab-panel { padding: 0 4px 4px; }

/* ── 教學頁面 — 功能總覽格子 ────────────────── */
.tut-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  padding: 4px 0 8px;
}
.tut-feature-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
  transition: box-shadow 0.15s, transform 0.15s;
}
.tut-feature-card:hover {
  box-shadow: 0 4px 12px rgba(45,106,79,0.12);
  transform: translateY(-2px);
}
.tut-feature-icon {
  font-size: 1.6rem;
  margin-bottom: 6px;
  background: #f0faf4;
  border-radius: 50%;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 8px;
  font-style: normal;
  color: var(--c-primary);
  font-weight: 700;
}
.tut-feature-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: #1f2937;
  margin-bottom: 4px;
}
.tut-feature-desc {
  font-size: 0.76rem;
  color: #6b7280;
  line-height: 1.4;
}

/* ── 雲端儲存教學 ────────────────────────────── */
.tut-cloud-keys {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tut-cloud-key {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1e1b4b;
  border-radius: 8px;
  padding: 8px 12px;
}
.tut-cloud-key-name {
  font-family: monospace;
  color: #a5b4fc;
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 160px;
}
.tut-cloud-key-desc {
  color: #c7d2fe;
  font-size: 0.8rem;
}
.tut-env-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 0.82rem;
}
.tut-env-table th {
  background: #f3f4f6;
  padding: 7px 10px;
  text-align: left;
  font-weight: 700;
  color: #374151;
  border: 1px solid #e5e7eb;
}
.tut-env-table td {
  padding: 7px 10px;
  border: 1px solid #e5e7eb;
  color: #374151;
  vertical-align: top;
}
.tut-env-table tr:nth-child(odd) td { background: #fafafa; }
.tut-env-table td:first-child {
  font-family: monospace;
  font-weight: 700;
  color: var(--c-primary);
  white-space: nowrap;
}

/* ── logo link ───────────────────────────────────────────────────────────── */
a.logo {
  text-decoration: none;
  color: inherit;
  font-weight: 700;
  font-size: 1.05rem;
}
a.logo:hover { opacity: 0.85; }

/* ── install banner ─────────────────────────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--c-primary);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 8000;
  font-size: 0.88rem;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
}
.install-banner span { flex: 1; }

/* ── tree-id photo section ───────────────────────────────────────────────── */
.tree-id-section {
  margin: 12px 0 8px;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  overflow: hidden;
}
.tree-id-toggle {
  width: 100%;
  background: #f0fdf4;
  border: none;
  padding: 12px 16px;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  color: #15803d;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tree-id-toggle .arrow { transition: transform 0.2s; }
.tree-id-toggle.open .arrow { transform: rotate(180deg); }
.tree-id-body {
  display: none;
  padding: 12px 16px;
  background: #fff;
}
.tree-id-body.open { display: block; }
.tree-id-hint {
  font-size: 0.82rem;
  color: #6b7280;
  margin: 0 0 10px;
}
.tree-id-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.tree-thumb-wrap {
  width: 72px; height: 72px;
  border-radius: 6px;
  overflow: hidden;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #9ca3af;
  border: 1px solid #e5e7eb;
  position: relative;
}
.tree-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
.tree-thumb-wrap.uploading { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }
.tree-id-add { margin-top: 4px; }

/* ── photo browser ───────────────────────────────────────────────────────── */
.photo-filter-form {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.photo-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.photo-filter-row label {
  display: flex;
  flex-direction: column;
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  gap: 4px;
  margin: 0;
}
.photo-filter-row select,
.photo-filter-row input[type="date"] {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.88rem;
}
.photo-plan-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.photo-plan-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.photo-plan-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.photo-plan-title {
  font-weight: 700;
  font-size: 1rem;
  color: #111827;
}
.photo-plan-date {
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.82rem;
  color: #374151;
}
.photo-plan-company, .photo-plan-loc {
  font-size: 0.82rem;
  color: #6b7280;
}
.photo-section-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #374151;
  margin: 8px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tree-section-label { color: #15803d; }
.photo-thumb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.photo-thumb-item {
  position: relative;
  width: 80px;
}
.photo-thumb-item img {
  width: 80px; height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  display: block;
}
.photo-thumb-meta {
  font-size: 0.8125rem;
  color: #6b7280;
  text-align: center;
  margin-top: 2px;
}
.photo-gps-badge {
  font-size: 0.65rem;
  text-align: center;
  margin-top: 1px;
  padding: 1px 3px;
  border-radius: 3px;
  line-height: 1.3;
  cursor: help;
}
.photo-gps-badge.gps-exif    { background: #dcfce7; color: #166534; }
.photo-gps-badge.gps-browser { background: #dbeafe; color: #1e40af; }
.photo-gps-badge.gps-none    { background: #f3f4f6; color: #9ca3af; }
.photo-dl-btn {
  position: absolute;
  top: 3px; right: 3px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.8rem;
  text-decoration: none;
  line-height: 1.4;
}
.photo-dl-btn:hover { background: rgba(0,0,0,0.75); }

/* ── worker greeting ─────────────────────────────────────────────────────── */
.worker-greeting {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--c-primary);
  padding: 4px 0 0;
  opacity: 0;
  transition: opacity 0.3s;
}
.worker-greeting.show { opacity: 1; }

/* ── dashboard progress bars ─────────────────────────────────────────────── */
.progress-cell { padding: 6px 10px; min-width: 140px; }
.mini-prog-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}
.mini-prog-label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #6b7280;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}
.mini-prog-bar {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}
.mini-prog-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}
.fill-before { background: #60a5fa; }
.fill-during { background: #f59e0b; }
.fill-after  { background: #34d399; }
.mini-prog-count {
  font-size: 0.8125rem;
  color: #6b7280;
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}
.mini-prog-count.prog-done { color: #059669; font-weight: 700; }

/* ── overdue ─────────────────────────────────────────────────────────────── */
.row-overdue td:first-child { background: #fff7ed; }
.deadline-badge {
  display: inline-block;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  margin-top: 3px;
  border: 1px solid #bfdbfe;
}
.overdue-badge {
  display: inline-block;
  background: #fef3c7;
  color: #b45309;
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-top: 3px;
  border: 1px solid #fcd34d;
}

/* ── dashboard 今日摘要 ──────────────────────────────────────────────────── */
.today-summary-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: #fff;
  border-radius: 12px;
  padding: 14px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  border: 1px solid #e5e7eb;
}
.tsb-item {
  flex: 1;
  text-align: center;
}
.tsb-num {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}
.tsb-label {
  display: block;
  font-size: 0.8125rem;
  color: #6b7280;
  margin-top: 4px;
  font-weight: 600;
}
.tsb-today .tsb-num  { color: var(--c-primary); }
.tsb-inprog .tsb-num { color: #d97706; }
.tsb-overdue .tsb-num { color: #dc2626; }
.tsb-ok .tsb-num     { color: #9ca3af; }
.tsb-divider {
  width: 1px;
  height: 40px;
  background: #e5e7eb;
  flex-shrink: 0;
}

/* ── board 今日工項 ──────────────────────────────────────────────────────── */
.today-plans-wrap {
  margin-bottom: 18px;
}
.today-plans-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--c-primary);
  padding: 10px 0 8px;
  border-bottom: 2px solid var(--c-primary-light);
  margin-bottom: 12px;
}
.today-plans-icon { font-size: 1.2rem; }
.today-plans-count {
  margin-left: auto;
  font-size: 0.82rem;
  font-weight: 700;
  background: #d1fae5;
  color: #065f46;
  padding: 2px 10px;
  border-radius: 99px;
}
.today-empty {
  text-align: center;
  color: #9ca3af;
  font-size: 0.92rem;
  padding: 18px;
  background: #f9fafb;
  border-radius: 10px;
  margin-bottom: 14px;
}
.plan-card-today {
  border-left-width: 5px;
  box-shadow: 0 2px 8px rgba(45,106,79,0.12);
}
.plan-progress-bars {
  margin-bottom: 10px;
}
.plan-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}
.plan-bar-label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #6b7280;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}
.plan-bar-track {
  flex: 1;
  height: 10px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}
.plan-bar-fill {
  height: 100%;
  background: var(--c-primary-light);
  border-radius: 99px;
  transition: width 0.4s ease;
  min-width: 3px;
}
.plan-bar-num {
  font-size: 0.8125rem;
  color: #6b7280;
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}
.plan-bar-num.bar-done { color: #059669; font-weight: 700; }

.btn-upload-big {
  padding: 14px;
  font-size: 1rem;
  border-radius: 10px;
  margin-top: 12px;
  letter-spacing: 0.02em;
}

.upload-legacy-link {
  display: block;
  text-align: center;
  margin-top: 6px;
  font-size: 0.78rem;
  color: #6b7280;
  text-decoration: underline;
  padding: 4px;
}
.upload-legacy-link:hover { color: #374151; }

/* ── board 本月其他工項（可折疊）────────────────────────────────────────── */
.other-plans-wrap {
  margin-bottom: 16px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  overflow: hidden;
}
.other-plans-toggle {
  width: 100%;
  background: #f9fafb;
  border: none;
  padding: 12px 16px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #374151;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
}
.other-plans-toggle .arrow { font-size: 1rem; transition: transform 0.2s; }
.other-plans-toggle.open .arrow { transform: rotate(180deg); }
.other-plans-body {
  display: none;
  padding: 12px;
}
.other-plans-body.open { display: block; }

/* ── upload sticky progress bar ─────────────────────────────────────────── */
.sticky-progress {
  position: sticky;
  top: calc(52px + env(safe-area-inset-top, 0px));   /* header + notch */
  z-index: 100;
  background: #fff;
  border-radius: 0 0 10px 10px;
  padding: 8px 14px;
  margin: -6px 0 10px;
  box-shadow: 0 3px 8px rgba(0,0,0,.1);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.jump-btn {
  margin-left: auto;
  background: #f59e0b;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.jump-btn:hover { opacity: 0.88; }

/* ── group card completion states ───────────────────────────────────────── */
.group-done    { border-left: 4px solid #16a34a; }
.group-partial { border-left: 4px solid #f59e0b; }

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.group-badge {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
}
.badge-done    { background: #d1fae5; color: #065f46; }
.badge-partial { background: #fef3c7; color: #92400e; }
.badge-empty   { background: #f1f5f9; color: #94a3b8; }

/* ── 施工後激勵彈窗 ─────────────────────────────────────────────────────── */
.cheer-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0,0,0,0);
  pointer-events: none;
  transition: background 0.25s;
}
.cheer-overlay.show {
  background: rgba(0,0,0,0.45);
  pointer-events: auto;
}
.cheer-box {
  background: #fff;
  border-radius: 22px;
  padding: 32px 28px 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 48px rgba(0,0,0,0.22);
  transform: scale(0.7) translateY(40px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s;
}
.cheer-overlay.show .cheer-box {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.cheer-emoji {
  font-size: 3.2rem;
  line-height: 1;
  margin-bottom: 12px;
  display: block;
  animation: cheer-bounce 0.6s ease 0.3s both;
}
@keyframes cheer-bounce {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.25); }
  80%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}
.cheer-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--c-primary);
  margin-bottom: 8px;
  line-height: 1.4;
}
.cheer-body {
  font-size: 0.95rem;
  color: #374151;
  line-height: 1.65;
  margin-bottom: 22px;
}
.cheer-close {
  background: var(--c-primary);
  color: #fff;
  border: none;
  border-radius: 99px;
  padding: 11px 36px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  letter-spacing: 0.03em;
}
.cheer-close:active { opacity: 0.85; }

/* ── 組別說明欄 ──────────────────────────────────────────────────────────────── */
.group-note-wrap {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
}
.group-note-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: 5px;
}
.group-note-hint {
  font-weight: 400;
  color: #9ca3af;
  font-size: 0.8125rem;
}
.group-note-input {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  color: #1f2937;
  background: #fafafa;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
}
.group-note-input:focus { border-color: var(--c-primary); background: #fff; }
.group-note-status {
  font-size: 0.8125rem;
  min-height: 16px;
  margin-top: 3px;
  text-align: right;
  color: #9ca3af;
}
.group-note-status.saving { color: #9ca3af; }
.group-note-status.saved  { color: #16a34a; }
.group-note-status.error  { color: #dc2626; }

/* ── 生態存摺地圖 ────────────────────────────────────────────────────────────── */

/* 地圖本體：全螢幕扣掉 header */
#map {
  position: fixed;
  top: 52px; left: 0; right: 0; bottom: 0;
  z-index: 0;
}

/* 地圖上方資訊列 */
.map-topbar {
  position: fixed;
  top: 52px; left: 0; right: 0;
  z-index: 500;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(6px);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-bottom: 1px solid #e5e7eb;
}
.map-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.map-title-text {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--c-primary);
}
.map-tree-count {
  font-size: 0.78rem;
  color: #6b7280;
  background: #f0faf4;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid #bbf7d0;
}
.map-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: #6b7280;
}
.leg-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.8);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  margin-left: 8px;
}
.leg-fresh    { background: #22c55e; }
.leg-recent   { background: #16a34a; }
.leg-due      { background: #eab308; }
.leg-overdue  { background: #f97316; }
.leg-critical { background: #dc2626; }
.leg-none     { background: #9ca3af; }

/* 樹木 marker */
.tree-marker-dot {
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.85);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* 剛維護（30 天內）marker 脈動（同時套用到 map marker 和 legend dot） */
.tree-marker-pulse {
  background: #22c55e !important;
  border-color: #fff !important;
  animation: tree-pulse 1.8s ease-out infinite;
}

@keyframes tree-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(34, 197, 94, 0.85), 0 1px 3px rgba(0,0,0,0.3); }
  70%  { box-shadow: 0 0 0 14px rgba(34, 197, 94, 0),    0 1px 3px rgba(0,0,0,0.3); }
  100% { box-shadow: 0 0 0 0   rgba(34, 197, 94, 0),    0 1px 3px rgba(0,0,0,0.3); }
}

/* MarkerCluster 自訂樣式 */
.cluster-icon {
  background: var(--c-primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 2px 8px rgba(45,106,79,0.4);
}

/* Cluster 含有剛維護的樹 → 金色光環脈動 */
.cluster-icon.cluster-has-recent {
  border-color: #fde047;
  animation: cluster-glow 2s ease-in-out infinite;
}

@keyframes cluster-glow {
  0%, 100% { box-shadow: 0 2px 8px rgba(45,106,79,0.4), 0 0 0 2px rgba(250, 204, 21, 0.9); }
  50%      { box-shadow: 0 2px 8px rgba(45,106,79,0.4), 0 0 0 10px rgba(250, 204, 21, 0.15); }
}

/* ── Bottom Sheet 樹木資訊面板 ──────────────────────────────────────────────── */
.tree-panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 600;
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
  max-height: 85vh;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
}
.tree-panel.open {
  transform: translateY(0);
}

/* 桌機：側邊面板 */
@media (min-width: 768px) {
  .tree-panel {
    left: auto;
    top: 90px; bottom: 20px;
    right: 16px;
    width: 360px;
    border-radius: 16px;
    max-height: calc(100vh - 110px);
    transform: translateX(120%);
  }
  .tree-panel.open {
    transform: translateX(0);
  }
}

.panel-drag-area {
  padding: 10px 0 6px;
  display: flex;
  justify-content: center;
  cursor: grab;
  flex-shrink: 0;
}
.panel-handle {
  width: 40px; height: 4px;
  background: #d1d5db;
  border-radius: 2px;
}
@media (min-width: 768px) {
  .panel-drag-area { display: none; }
}

.panel-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 0 16px 24px;
  -webkit-overflow-scrolling: touch;
}

/* 樹木基本資訊 */
.tree-info-section { padding-bottom: 4px; }

.tree-name-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.tree-species-icon { font-size: 2rem; flex-shrink: 0; margin-top: 2px; }
.tree-species {
  font-size: 1.15rem;
  font-weight: 800;
  color: #1f2937;
  line-height: 1.3;
}
.tree-sci {
  font-size: 0.78rem;
  color: #6b7280;
  font-style: italic;
  margin-top: 2px;
}
.panel-close-btn {
  margin-left: auto;
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 0.85rem;
  cursor: pointer;
  color: #6b7280;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.tree-tag {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* 固碳量卡片 */
.carbon-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border: 1px solid #86efac;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.carbon-icon { font-size: 1.6rem; flex-shrink: 0; }
.carbon-title { font-size: 0.8125rem; font-weight: 700; color: #166534; margin-bottom: 2px; }
.carbon-val   { font-size: 1rem; font-weight: 800; color: #15803d; }
.carbon-story { font-size: 0.8125rem; color: #4ade80; margin-top: 2px; color: #166534; opacity: 0.8; }

/* 最後維護卡片 */
.maintain-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 4px;
}
.maintain-icon    { font-size: 1.3rem; flex-shrink: 0; margin-top: 2px; }
.maintain-company { font-size: 0.88rem; font-weight: 700; color: #1f2937; }
.maintain-date    { font-size: 0.78rem; color: #6b7280; }
.maintain-type    { font-size: 0.78rem; color: var(--c-primary); font-weight: 600; margin-top: 2px; }

/* 分隔線 */
.panel-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #374151;
  padding: 14px 0 10px;
  border-top: 1px solid #f1f5f9;
  margin-top: 8px;
}
.msg-count-badge {
  font-size: 0.8125rem;
  background: #fef3c7;
  color: #92400e;
  padding: 1px 7px;
  border-radius: 99px;
  font-weight: 700;
}

/* ── 留言牌 ─────────────────────────────────────────────────────────────────── */
.msg-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.msg-loading, .msg-empty {
  text-align: center;
  color: #9ca3af;
  font-size: 0.85rem;
  padding: 20px 0;
}

.msg-tag {
  border-radius: 10px 10px 10px 2px;
  padding: 12px 14px;
  position: relative;
  box-shadow: 0 2px 6px rgba(0,0,0,0.07);
}
/* 小繩子裝飾 */
.msg-tag-string {
  position: absolute;
  top: -10px; left: 18px;
  width: 2px; height: 10px;
  background: #a16207;
  border-radius: 1px;
}
.msg-tag-mood   { font-size: 1.4rem; line-height: 1; margin-bottom: 4px; }
.msg-tag-text   { font-size: 0.9rem; line-height: 1.55; margin-bottom: 8px; word-break: break-all; }
.msg-tag-footer { display: flex; justify-content: space-between; align-items: center; }
.msg-tag-nick   { font-size: 0.8125rem; font-weight: 700; opacity: 0.75; }
.msg-tag-date   { font-size: 0.8125rem; opacity: 0.55; }

/* ── 留言表單 ───────────────────────────────────────────────────────────────── */
.msg-form-wrap {
  border-top: 1px solid #f1f5f9;
  padding-top: 14px;
}
.msg-form-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: 10px;
}
.mood-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.mood-btn {
  font-size: 1.3rem;
  background: #f9fafb;
  border: 2px solid transparent;
  border-radius: 10px;
  width: 40px; height: 40px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.mood-btn.active  { border-color: var(--c-primary); background: #f0fdf4; }
.mood-btn:hover   { background: #f0fdf4; }

.msg-input {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fafafa;
  margin-bottom: 8px;
  font-family: inherit;
  color: #1f2937;
  outline: none;
  transition: border-color 0.15s;
}
.msg-input:focus { border-color: var(--c-primary); background: #fff; }
.msg-textarea { resize: none; line-height: 1.55; }
.msg-char-hint {
  text-align: right;
  font-size: 0.8125rem;
  color: #9ca3af;
  margin: -4px 0 10px;
}
.msg-submit-btn {
  width: 100%;
  background: var(--c-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: opacity 0.15s;
}
.msg-submit-btn:hover   { opacity: 0.9; }
.msg-submit-btn:disabled{ opacity: 0.55; cursor: not-allowed; }

/* ── 匯入頁 ─────────────────────────────────────────────────────────────────── */
.import-stat-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.9rem;
  color: #166534;
}

/* ── Plan assignment chips ───────────────────────────────────────────────── */
.assign-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.assign-chip  { font-size: 0.8rem; background: #dbeafe; color: #1e40af;
                padding: 1px 7px; border-radius: 99px; font-weight: 600; }

/* ── Board worker selector bar ───────────────────────────────────────────── */
.board-worker-bar {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 10px; padding: 10px 16px;
  margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.07);
  border-left: 4px solid var(--c-primary);
}
.board-worker-label { font-size: 14px; font-weight: 700; color: #374151; white-space: nowrap; }
.board-worker-select { flex: 1; padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.board-worker-hint { font-size: 12px; font-weight: 600; }
.import-stat-icon { font-size: 1.4rem; flex-shrink: 0; }

/* ── Mobile cards for admin plans table (≤720px) ────────────────────────── */
@media (max-width: 720px) {
  .plans-table-mobile-wrap { overflow: visible !important; }
  .plans-table-mobile-wrap::after { content: none !important; }
  .dash-table.plans-table-mobile { min-width: 0 !important; width: 100%; border-collapse: separate; }
  .dash-table.plans-table-mobile thead { display: none; }
  .dash-table.plans-table-mobile,
  .dash-table.plans-table-mobile tbody,
  .dash-table.plans-table-mobile tr,
  .dash-table.plans-table-mobile td { display: block; width: 100%; }
  .dash-table.plans-table-mobile tr {
    border: 1px solid #e5e7eb; border-radius: 10px;
    margin: 0 0 10px 0; padding: 10px 12px; background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
  }
  .dash-table.plans-table-mobile td {
    border: none; padding: 4px 0; font-size: 14px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  }
  .dash-table.plans-table-mobile td.center,
  .dash-table.plans-table-mobile td.doc-cell,
  .dash-table.plans-table-mobile td.action-cell { text-align: left; }
  .dash-table.plans-table-mobile td.progress-cell { display: block; }
  .dash-table.plans-table-mobile td::before {
    content: attr(data-label) "："; font-weight: 600; color: #374151; min-width: 64px;
  }
  .dash-table.plans-table-mobile td.progress-cell::before { display: block; margin-bottom: 4px; }
  .dash-table.plans-table-mobile td.action-cell { flex-wrap: wrap; gap: 6px; }
  .dash-table.plans-table-mobile td.action-cell form { display: inline-block; }
}

/* ── Dark mode disabled — 內部管理系統維持淺色主題 ── */

/* ── Xiao-Qing guidance bubble (.xq) — global helper component ─────────── */
/* Used across operational pages for inline tips, warnings, and info notes.  */
/* Variants: .xq.tip (green), .xq.warn (amber), .xq.info (blue)             */
.xq {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: 8px; margin: 8px 0;
  border-left: 3px solid #22c55e; background: #f0fdf4;
  font-size: 13px; line-height: 1.6;
}
.xq.warn  { background: #fff7ed; border-left-color: #f59e0b; }
.xq.info  { background: #eff6ff; border-left-color: #3b82f6; }
.xq-ico {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  background: #22c55e; color: #fff; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.xq.warn .xq-ico  { background: #f59e0b; }
.xq.info .xq-ico  { background: #3b82f6; }
.xq-text          { color: #166534; flex: 1; }
.xq.warn .xq-text { color: #92400e; }
.xq.info .xq-text { color: #1e40af; }

/* ── tut-warn-box — amber warning box for dangerous / irreversible ops ──── */
.tut-warn-box {
  background: #fff7ed; border: 1px solid #fed7aa;
  border-radius: 8px; padding: 10px 13px;
  font-size: 13px; color: #92400e; line-height: 1.6;
}
.tut-warn-box.danger {
  background: #fef2f2; border-color: #fca5a5; color: #991b1b;
}
