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

:root {
  --primary: #FF0080;
  --primary-dark: #D40069;
  --primary-light: #FF4DA6;
  --primary-bg: #FFF0F7;
  --space-900: #0C0920;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #0C0920;
  --sidebar-w: 224px;
  --header-h: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif; color: var(--gray-900); background: #fff; }

/* ── Login ─────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--space-900) 0%, #1a0833 50%, #3d0026 100%); }
.login-card { background: #fff; border-radius: 12px; padding: 40px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.login-logo p { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: 8px; font-size: 14px; outline: none; transition: border .15s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,0,128,.12); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border: none; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s, opacity .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
/* 儲存類按鈕一律黃色（全站統一：儲存、儲存備註、儲存設定…） */
.btn-save { background: #f59e0b; color: #fff; }
.btn-save:hover { background: #d97706; }
.btn-ghost { background: transparent; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; text-align: center; }

/* ── Layout ─────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar { width: var(--sidebar-w); background: var(--space-900); color: #fff; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh; z-index: 100; }
.sidebar-brand { padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand h2 { font-size: 14px; font-weight: 700; font-family: 'Orbitron', 'Noto Sans TC', sans-serif; letter-spacing: .5px; color: var(--primary-light); display:flex; align-items:center; }
.sidebar-brand p { font-size: 11px; opacity: .6; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; overflow-anchor: none; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 20px; font-size: 14px; color: rgba(255,255,255,.75); text-decoration: none; cursor: pointer; transition: background .15s, color .15s; border: none; background: none; width: 100%; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(255,0,128,.45); color: #fff; border-left: 3px solid var(--primary); padding-left: 17px; font-weight: 600; }
.nav-item .icon { font-size: 18px; width: 22px; text-align: center; }
.nav-group-label { display: block; padding: 10px 20px 3px; font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: rgba(255,255,255,.35); user-select: none; margin-top: 4px; }
/* ── 選單瘦身：分組收合＋我的最愛（2026-08-26）──
   順序完全不動，只是可以收起來，另外在最上面加一區釘選的常用功能。 */
/* 分組標題現在是按鈕了，要看得清楚也點得到。
   原本 10px／35% 白是純標籤的尺寸，全部收起來時整個選單只剩一排灰字
   —— 佳樺 2026-08-26：「選單預設縮起來有點小」。 */
.nav-group-toggle { cursor: pointer; display: flex; align-items: center; gap: 7px;
                    font-size: 11.5px; color: rgba(255,255,255,.55); padding: 9px 20px 6px;
                    min-height: 34px; box-sizing: border-box; }
.nav-group-toggle:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-group-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.nav-group-toggle::before { content: '\25B8'; font-size: 10px; transition: transform .15s;
                            display: inline-block; opacity: .8; }
.nav-group-toggle[data-open="1"]::before { transform: rotate(90deg); }
.nav-item[data-collapsed="1"] { display: none; }
.nav-item { position: relative; }
.nav-star { margin-left: auto; font-size: 14px; line-height: 1; padding: 4px 6px; opacity: 0;
            color: rgba(255,255,255,.45); transition: opacity .15s, color .15s; flex-shrink: 0; }
.nav-item:hover .nav-star { opacity: 1; }
.nav-star:hover { color: #ffd166; }
.nav-star.on { opacity: 1; color: #ffd166; }
/* 手機沒有滑鼠 hover，星星永遠不會出現 —— 觸控裝置一律常駐（淡一點） */
@media (hover: none) {
  .nav-star { opacity: .5; padding: 8px 10px; }      /* 順便放大成點得到的大小 */
  .nav-group-toggle { min-height: 42px; font-size: 12.5px; }
}
.nav-collapse-all { display: block; width: calc(100% - 24px); margin: 4px 12px 8px;
                    padding: 7px 10px; font-size: 11.5px; font-family: inherit;
                    color: rgba(255,255,255,.6); background: rgba(255,255,255,.06);
                    border: 1px solid rgba(255,255,255,.12); border-radius: 7px;
                    cursor: pointer; text-align: center; }
.nav-collapse-all:hover { color: #fff; background: rgba(255,255,255,.13); }
@media (hover: none) { .nav-collapse-all { min-height: 40px; font-size: 13px; } }
.nav-fav-box:not(:empty) { padding-bottom: 6px; margin-bottom: 4px;
                           border-bottom: 1px solid rgba(255,255,255,.1); }
.nav-fav-box .nav-group-label { color: rgba(255,209,102,.85); }
/* 最愛排序（2026-10-05）：桌機直接拖；手機／鍵盤按「↕ 排序」出現 ▲ ▼ */
.nav-fav-head { display: flex; align-items: center; gap: 6px; }
.nav-fav-sort { margin: -3px 0 -3px auto; padding: 1px 7px; font-size: 10px; line-height: 1.5;
                font-family: inherit; letter-spacing: 0; color: rgba(255,209,102,.85);
                background: transparent; border: 1px solid rgba(255,209,102,.35);
                border-radius: 6px; cursor: pointer; }
.nav-fav-sort:hover, .nav-fav-sort[aria-pressed="true"] { color: #1a1a2e; background: #ffd166; }
.nav-fav-box .nav-item[draggable="true"] { cursor: grab; }
.nav-fav-box.sorting .nav-item { cursor: default; }
.nav-fav-box .nav-item.fav-dragging { opacity: .4; }
.nav-fav-box .nav-item.fav-drop-before { box-shadow: inset 0 2px 0 #ffd166; }
.nav-fav-box .nav-item.fav-drop-after  { box-shadow: inset 0 -2px 0 #ffd166; }
.nav-fav-move { margin-left: auto; display: flex; gap: 3px; flex-shrink: 0; }
/* 選單紅色數字＝等我審核／確認的件數（2026-10-05，common.js applyNavBadges）。
   分組標題上的是整組加總：只有收起來時才顯示（展開時每項各自有，同一件事只提醒一次）。 */
.nav-badge { display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 6px; border-radius: 9px;
             background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px;
             text-align: center; letter-spacing: 0; flex-shrink: 0; box-sizing: border-box; }
.nav-group-label[data-open="1"] > .nav-badge { display: none; }
.nav-fav-move button { font-size: 10px; line-height: 1; padding: 3px 6px; font-family: inherit;
                       color: #ffd166; background: rgba(255,255,255,.08);
                       border: 1px solid rgba(255,209,102,.35); border-radius: 5px; cursor: pointer; }
.nav-fav-move button:disabled { opacity: .25; cursor: default; }
.nav-fav-move button:focus-visible, .nav-fav-sort:focus-visible { outline: 2px solid #ffd166; outline-offset: 1px; }
@media (hover: none) {
  .nav-fav-sort { padding: 4px 10px; font-size: 12px; }
  .nav-fav-move button { padding: 6px 10px; font-size: 12px; }
}
/* 側邊欄的分店切換器：收起來是深底白字，但展開後的選項由作業系統繪製，
   會沿用白字 → 白字白底完全看不到（2026-08-31 Peggy 回報）。
   option 一律指定深色字＋白底；順便宣告 color-scheme 讓系統畫得更一致。 */
.org-switch { color-scheme: light; }
.org-switch option { color: #111418; background: #ffffff; }
.org-switch option:checked { background: #e8eefc; }
.sidebar-user { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; }
.sidebar-user .user-name { font-weight: 600; }
.sidebar-user .user-role { opacity: .6; font-size: 12px; margin-top: 2px; }
.logout-btn { margin-top: 10px; font-size: 12px; color: rgba(255,255,255,.5); cursor: pointer; background: none; border: none; padding: 0; }
.logout-btn:hover { color: #fff; }

.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column;
  /* min-width:0 —— flex 子項預設不會縮到比內容窄，寬表格會把整個主區塊撐得比螢幕還寬，
     .table-wrap 的左右捲動就失效、右邊的欄位被推出畫面（2026-09-29 Tanya：膜料使用紀錄看不到右邊）*/
  min-width: 0; }

.top-bar { height: var(--header-h); background: #fff; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: var(--org-banner-h, 0px); z-index: 50; }
.page-title { font-size: 17px; font-weight: 600; }

.page-body { padding: 24px; flex: 1; }

/* ── Cards & Stats ──────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 10px; padding: 18px 20px; border: 1px solid var(--gray-200); }
.stat-card .label { font-size: 12px; color: var(--gray-500); margin-bottom: 8px; }
.stat-card .value { font-size: 26px; font-weight: 700; }
.stat-card .value.danger { color: var(--danger); }
.stat-card .value.success { color: var(--success); }
.stat-card .value.warning { color: var(--warning); }

.card { background: #fff; border-radius: 10px; border: 1px solid var(--gray-200); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── Table ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { background: var(--gray-50); padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600; color: var(--gray-500); border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:nth-child(odd)  { background: #fff; }
tbody tr:nth-child(even) { background: #f8fafc; }
tr:hover td { background: #eef2ff !important; }

/* ── Badges ─────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge-inquiry          { background: #fef3c7; color: #92400e; }
.badge-initial_estimate { background: #e0f2fe; color: #0369a1; }
.badge-cared_waiting    { background: #ffedd5; color: #9a3412; }
.badge-quote_needed     { background: #fdf4ff; color: #a21caf; }
.badge-quote_sent       { background: #d1fae5; color: #065f46; }
.badge-survey_pending   { background: #fff7ed; color: #c2410c; }
.badge-survey_scheduled { background: #ede9fe; color: #6d28d9; }
.badge-surveyed         { background: #ccfbf1; color: #0f766e; }
.badge-quote_draft      { background: #fdf4ff; color: #a21caf; }
.badge-quoted           { background: #fef9c3; color: #713f12; }
.badge-contracted       { background: #dbeafe; color: #1e40af; }
.badge-dispatched       { background: #e0e7ff; color: #3730a3; }
.badge-constructing     { background: #fef08a; color: #713f12; }
.badge-payment          { background: #fed7aa; color: #92400e; }
.badge-closed           { background: #d1fae5; color: #065f46; }
.badge-invalid          { background: var(--gray-100); color: var(--gray-500); }
.badge-tech_accepted    { background: #ffe4e6; color: #9f1239; }
.badge-aftersales       { background: #f472b6; color: #fff; }
.badge-intent-called        { background: #d1fae5; color: #065f46; }
.badge-intent-incomplete    { background: #fed7aa; color: #c2410c; }
.badge-intent-waiting_quote { background: #dbeafe; color: #1e40af; }
.badge-intent-need_survey   { background: #ede9fe; color: #6d28d9; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-partial { background: #fef9c3; color: #713f12; }
.badge-unpaid { background: #fee2e2; color: #991b1b; }

/* ── Filters ────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filter-bar select, .filter-bar input { padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: 8px; font-size: 13px; background: #fff; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 680px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 16px; font-weight: 600; }

/* 手機：彈窗要接近全螢幕，而不是被上下 40px 內距擠成一小塊、內容一長就被推到底部。
   標題與底部按鈕固定，只有中間內容捲動 —— 師傅在工地單手操作才不會找不到按鈕。 */
@media (max-width: 768px) {
  .modal-overlay { padding: 10px 8px; align-items: flex-start; }
  .modal { max-width: 100%; max-height: 94vh; display: flex; flex-direction: column; }
  .modal-header { padding: 14px 16px; flex-shrink: 0; }
  .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; }
  .modal-footer { flex-shrink: 0; }
  /* 按鈕在手機上要夠大才點得到（戴手套） */
  .modal-footer .btn { min-height: 44px; }
}
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-500); line-height: 1; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 10px; }
.modal-section-title { font-size: 11px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: .07em; padding: 10px 0 8px; border-top: 1px solid var(--gray-200); margin-top: 8px; }
.client-tag { display:inline-flex;align-items:center;gap:3px;padding:2px 7px;border-radius:10px;font-size:11px;font-weight:500;color:#fff; }
.tag-check-item { display:flex;align-items:center;gap:8px;padding:5px 8px;border-radius:6px;cursor:pointer; }
.tag-check-item:hover { background:var(--gray-100); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
/* display:grid 會蓋過 hidden 屬性：費用申請的「車種／公里數」本來只給油錢補貼，卻每個科目都跑出來（佳樺 2026-10-02） */
.form-row[hidden] { display: none; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Calendar ───────────────────────────────────────────── */
.cal-nav { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.cal-nav h2 { font-size: 18px; font-weight: 700; min-width: 140px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--gray-200); border: 1px solid var(--gray-200); border-radius: 10px; overflow: hidden; }
.cal-header-cell { background: var(--gray-50); padding: 10px; text-align: center; font-size: 12px; font-weight: 600; color: var(--gray-500); }
.cal-cell { background: #fff; min-height: 110px; padding: 8px; cursor: pointer; transition: background .15s; }
.cal-cell:hover { background: #f0f4ff; }
.cal-cell.other-month { background: var(--gray-50); }
.cal-cell.today .cal-day { background: var(--primary); color: #fff; }
.cal-day { display: inline-block; width: 26px; height: 26px; border-radius: 50%; text-align: center; line-height: 26px; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.cal-revenue { font-size: 11px; margin-bottom: 4px; font-weight: 600; }
.cal-revenue.over { color: var(--danger); }
.cal-revenue.under { color: var(--warning); }
.cal-revenue.ok { color: var(--success); }
.cal-case-pill { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: #e5e7eb; color: #374151; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-case-pill.survey      { background: #dbeafe; color: #1e40af; }
.cal-case-pill.contracted  { background: #fee2e2; color: #991b1b; }
.cal-case-pill.payment     { background: #fed7aa; color: #92400e; }
.cal-case-pill.closed      { background: #d1fae5; color: #065f46; }
.unscheduled-list { margin-top: 20px; }
.unscheduled-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--gray-200); border-radius: 8px; margin-bottom: 8px; background: #fff; }
.unscheduled-item .case-num { font-size: 12px; color: var(--gray-500); font-family: monospace; }

/* ── Hamburger / Mobile Nav ──────────────────────────────── */
.mobile-menu-btn {
  display: none; background: none; border: none; cursor: pointer;
  padding: 6px 8px; border-radius: 8px; color: var(--gray-700);
  flex-direction: column; gap: 5px; margin-right: 12px;
}
.mobile-menu-btn span { display: block; width: 22px; height: 2px; background: currentColor; border-radius: 2px; transition: all .2s; }
/* 無 top-bar 的頁面（個人資料/合約/使用說明）用浮動漢堡，避免手機上無法叫出選單被困住 */
.mobile-menu-btn-floating { position: fixed; top: 10px; left: 10px; z-index: 101; background: #fff; box-shadow: 0 1px 5px rgba(0,0,0,.18); margin-right: 0; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }
.sidebar-backdrop.open { display: block; }

/* ── 桌機：左側欄收合（縮成只剩圖示，讓內容變大）───────────── */
.sb-collapse-btn { position: fixed; top: 16px; left: var(--sidebar-w); transform: translateX(-50%);
  z-index: 101; width: 24px; height: 24px; border-radius: 50%; background: var(--primary, #d6336c);
  color: #fff; border: 2px solid #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; line-height: 1; padding: 0; box-shadow: 0 2px 6px rgba(0,0,0,.28);
  transition: left .18s; }
.sb-collapse-btn:hover { filter: brightness(1.08); }
@media (min-width: 769px) {
  html.sb-collapsed { --sidebar-w: 64px; }
  html.sb-collapsed .sidebar-brand { padding: 16px 0; text-align: center; }
  html.sb-collapsed .sidebar-brand h2 { font-size: 0; justify-content: center; }
  html.sb-collapsed .sidebar-brand h2 img { margin-right: 0 !important; }
  html.sb-collapsed .sidebar-brand p { display: none; }
  html.sb-collapsed .nav-group-label { font-size: 0; padding: 6px 0; }
  html.sb-collapsed .nav-fav-sort, html.sb-collapsed .nav-fav-move { display: none; }
  html.sb-collapsed .nav-item { font-size: 0; gap: 0; justify-content: center; padding-left: 0; padding-right: 0; }
  html.sb-collapsed .nav-item .icon { font-size: 19px; width: auto; }
  html.sb-collapsed .nav-item.active { padding-left: 0; border-left-width: 3px; }
  html.sb-collapsed .nav-badge { position: absolute; top: 3px; right: 6px; margin: 0; font-size: 10px; min-width: 16px; line-height: 16px; padding: 0 4px; }
  html.sb-collapsed .nav-group-label > .nav-badge { display: none; }
  html.sb-collapsed .sidebar-user { font-size: 0; padding: 14px 4px; text-align: center; }
  html.sb-collapsed .sidebar-user * { font-size: 0; }
}
@media (max-width: 768px) { .sb-collapse-btn { display: none; } }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform .25s; z-index: 100; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .top-bar { padding: 0 12px; gap: 8px; }
  /* 頁首那一排按鈕在手機上不能被擠成直的。
     2026-09-15 佳樺在 iPhone 開人事資料：標題「人事資料管理」跟六顆按鈕
     全部一個字一個字疊成直排 —— flex 把每個項目壓到只剩一個字寬，
     文字就逐字換行。標題與按鈕都不准縮、不准換行，按鈕那一排改成橫向捲。
     cases／materials／ledger 也是同一種版型，一起修。 */
  .top-bar .page-title { white-space: nowrap; flex-shrink: 0; font-size: 15px; }
  /* 標題太長（LINE OA 詢問管理）會把右上的 🔔 擠出畫面（2026-10-02 手機搜尋實測）：
     標題照樣不換行（不會變直排），但空間不夠時讓它縮、超過用 …；🔍／Aa／?／🔔 不縮 */
  .top-bar .page-title { flex-shrink: 1; min-width: 2.5em; overflow: hidden; text-overflow: ellipsis; }
  .top-bar { gap: 4px; padding: 0 10px; }
  .top-bar > div:not(.notif-wrap) { min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .top-bar > div:not(.notif-wrap)::-webkit-scrollbar { display: none; }
  /* 鈴鐺／Aa 的下拉是 absolute 掛在 .notif-wrap（position:relative）底下；上面那條
     overflow-x:auto 一套到它身上，下拉就被裁成鈴鐺那麼大——手機上按鈴鐺看起來「沒反應」
     （佳樺 2026-09-21 深夜）。這幾個小包裝一定要 overflow 可見。 */
  .top-bar > .notif-wrap { overflow: visible; flex-shrink: 0; }
  .top-bar .btn { white-space: nowrap; flex-shrink: 0; }
  /* 分頁列（財務報表的 損益表／業績報表／現金流量表…）在手機被擠成一個字一行的直排
     （佳樺 2026-10-02 截圖）→ 不准換行、不准縮，改成整排左右滑 */
  .tab-bar, .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tab-bar::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
  .tab-bar > *, .tabs > * { white-space: nowrap; flex-shrink: 0; }
  /* 頁首的主要動作鈕（＋新增申請、＋申請請假）在手機被擠出畫面外，看起來「沒有新增功能」
     （佳樺 2026-10-01 手機費用申請）→ 加 .mobile-fab 的按鈕在手機改成右下角浮動圓鈕 */
  .top-bar .btn.mobile-fab { position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 90;
    padding: 14px 20px; font-size: 17px; border-radius: 999px; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
  .page-body { padding: 16px 12px; }
  /* 沒有 .top-bar、只有 .page-header 標題的頁面（案件分潤／特約結算）：☰ 是左上角浮動的，
     標題要讓出位置，不然 ☰ 壓在標題上（佳樺 2026-10-05 手機截圖）。桌機沒有 ☰，不受影響。 */
  .page-header { display: flex; align-items: center; min-height: 50px; padding: 8px 12px 4px 60px; }
  .page-header .page-title { font-size: 16px; font-weight: 700; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  /* 表格在手機自動捲動 */
  table { min-width: 520px; }
  /* Modal 全寬 */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; overflow-y: auto; }
  /* 卡片 header 可換行 */
  .card-header { flex-wrap: wrap; gap: 8px; }
  /* filter bar 單行捲動 */
  .filter-bar { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .filter-bar select, .filter-bar input { flex-shrink: 0; }
  /* 手機輸入框一律 16px（2026-08-17）：iOS 只要輸入框小於 16px，
     一點下去就自動放大整頁、畫面亂跳，同事填申請單常常打錯欄位。
     這條一次涵蓋全站的申請表單（請假、加班、費用、膜料領用…）。 */
  .form-group input, .form-group select, .form-group textarea,
  .filter-row input, .filter-row select,
  .filter-bar input, .filter-bar select { font-size: 16px; }
  /* 可點區域至少 44px（Apple 建議下限），戴手套也點得到 */
  .form-group input, .form-group select { min-height: 44px; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }
  /* 分頁籤太多時橫向捲動，不要擠成兩三行把內容推下去 */
  .tabs-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tabs-bar .tab { flex-shrink: 0; }
  /* 表格一律可以橫向捲，避免整頁被撐寬（沒有 .table-wrap 的頁面也適用） */
  .card-body > table, .page-body > table { display: block; overflow-x: auto; }
  /* 視窗裡用行內樣式寫死的兩欄排版（資產借用、請假等申請表單）在手機收成一欄。
     行內樣式蓋不掉，只能用屬性選擇器 + !important。 */
  .modal-body [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  .modal-body .form-row[style*="display:flex"] { flex-direction: column; gap: 0 !important; }
  /* 行事曆縮小 */
  .cal-cell { min-height: 70px; padding: 4px; }
  .cal-case-pill { font-size: 10px; }
}

.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-500); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }

/* ── 通知鈴鐺 ────────────────────────────────────────────── */
.notif-wrap { position: relative; margin-left: 8px; }
.notif-bell { background: none; border: none; cursor: pointer; font-size: 18px; padding: 4px 8px; border-radius: 8px; position: relative; line-height: 1; }
.notif-bell:hover { background: var(--gray-100); }
.ui-scale-opt.on { background: #fdf2f8; color: var(--primary); font-weight: 700; }
.ui-scale-opt:hover { background: var(--gray-100); }
.notif-badge { position: absolute; top: -2px; right: -2px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; text-align: center; line-height: 18px; padding: 0 4px; }
.notif-dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 320px; background: #fff; border: 1px solid var(--gray-200); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.12); z-index: 200; }
.notif-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--gray-100); font-size: 14px; font-weight: 600; }
.notif-read-all { background: none; border: none; font-size: 12px; color: var(--primary); cursor: pointer; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); cursor: pointer; transition: background .1s; }
/* 鈴鐺每一則是 <a target="_blank">（另開視窗進對話）——外觀要跟原本的 <div> 一模一樣 */
a.notif-item { display: block; color: inherit; text-decoration: none; }
.notif-item:hover { background: var(--gray-50); }
.notif-item.unread { background: #eff6ff; }
.notif-item:last-child { border-bottom: none; }

/* ── 萬用搜尋（跨階段找案件）────────────────────────────────── */
.gsearch-wrap { position: relative; margin-left: auto; display: flex; align-items: center; }
.gsearch-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .5; pointer-events: none; }
.gsearch-input { width: 280px; max-width: 38vw; padding: 8px 14px 8px 34px; border: 1px solid var(--gray-200); border-radius: 20px; font-size: 13px; outline: none; background: var(--gray-50); transition: border-color .12s, background .12s; }
.gsearch-input:focus { border-color: var(--primary); background: #fff; }
.gsearch-dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 420px; max-width: 92vw; max-height: 70vh; overflow-y: auto; background: #fff; border: 1px solid var(--gray-200); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.14); z-index: 200; }
.gs-item { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--gray-100); cursor: pointer; }
.gs-item:hover { background: var(--gray-50); }
.gs-item:last-child { border-bottom: none; }
.gs-badge { flex-shrink: 0; width: 58px; text-align: center; padding: 5px 0; border-radius: 7px; font-size: 11px; font-weight: 700; color: #fff; }
.gs-line { background: #06c755; } .gs-inq { background: #5b8def; } .gs-survey { background: #f0962d; } .gs-quote { background: #9b59d0; } .gs-deal { background: #2bb673; }
.gs-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.gs-row1 { font-size: 14px; font-weight: 600; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-cno { color: var(--primary); font-weight: 700; margin-right: 6px; }
.gs-row2 { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.gs-row3 { font-size: 11px; color: var(--gray-400); margin-top: 3px; }
.gs-cost { color: #c0392b; font-weight: 600; }
.gs-sep { margin: 0 6px; opacity: .4; }
.gs-empty { padding: 24px; text-align: center; color: var(--gray-400); font-size: 13px; }
/* 搜尋結果的「用過這款膜料的案件」分區（2026-08-26） */
.gs-sect { padding: 9px 14px 6px; font-size: 12px; font-weight: 700; color: #0f766e;
           background: #f0fdfa; border-top: 1px solid var(--gray-200); position: sticky; top: 0; }
.gs-used { color: #0f766e; font-weight: 700; }
.gs-note { padding: 7px 14px 10px; font-size: 11.5px; color: var(--gray-500);
           background: #fafafa; border-top: 1px solid var(--gray-100); line-height: 1.6; }
@media (max-width: 768px) { .gsearch-input { width: 140px; } .gsearch-dropdown { width: 88vw; } }
/* 手機搜尋（佳樺 2026-10-02）：平常只留 🔍；按了整排展開蓋在頁首上，✕／返回收起 */
.gsearch-toggle, .gsearch-close { display: none; border: none; background: none; cursor: pointer; font-size: 18px; min-width: 40px; height: 40px; border-radius: 10px; color: var(--gray-700); }
@media (max-width: 768px) {
  .top-bar > .gsearch-wrap.gsearch-wrap { overflow: visible; flex-shrink: 0; min-width: 0; }
  .gsearch-toggle { display: flex; align-items: center; justify-content: center; }
  .gsearch-wrap:not(.open) .gsearch-input, .gsearch-wrap:not(.open) .gsearch-icon { display: none; }
  .gsearch-wrap.open { position: fixed; left: 0; right: 0; top: var(--org-banner-h, 0px); height: var(--header-h); z-index: 160;
    background: #fff; border-bottom: 1px solid var(--gray-200); padding: 0 8px 0 12px; gap: 6px; margin: 0; }
  .gsearch-wrap.open .gsearch-toggle { display: none; }
  .gsearch-wrap.open .gsearch-close { display: flex; align-items: center; justify-content: center; }
  .gsearch-wrap.open .gsearch-icon { left: 24px; }
  .gsearch-wrap.open .gsearch-input { flex: 1; width: auto; max-width: none; font-size: 16px; padding: 10px 14px 10px 36px; }
  .gsearch-wrap.open .gsearch-dropdown { position: fixed; left: 8px; right: 8px; width: auto; max-width: none;
    top: calc(var(--org-banner-h, 0px) + var(--header-h) + 4px); max-height: 75vh; }
}
.notif-title { font-size: 13px; font-weight: 600; color: var(--gray-800); margin-bottom: 3px; }
.notif-body { font-size: 12px; color: var(--gray-500); line-height: 1.5; margin-bottom: 4px; }
.notif-time { font-size: 11px; color: var(--gray-400); }
.notif-empty { padding: 24px; text-align: center; font-size: 13px; color: var(--gray-500); }
@media (max-width: 768px) {
  /* 手機：鈴鐺可能被擠到第二行最左邊，用 absolute 會跑出畫面（2026-10-04 案件頁）→ 固定貼著畫面兩側 */
  .notif-dropdown { position: fixed; left: 8px; right: 8px; top: calc(env(safe-area-inset-top, 0px) + 64px); width: auto; max-height: 70vh; overflow-y: auto; }
}

@media (max-width: 768px) {
  #sf_sigCanvas { height: 180px !important; }
}
.tag-target-form { display: flex; gap: 8px; align-items: center; font-size: 13px; }

/* ── Toast 右上角提示 ────────────────────────────────────── */
.toast {
  padding: 12px 18px; border-radius: 8px; color: #fff;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  opacity: 0; transform: translateX(20px);
  transition: opacity .2s, transform .2s;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  max-width: 320px; word-break: break-word; white-space: normal;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info    { background: #0ea5e9; }

/* ── 正中央大提示（用於刪除成功等重要操作）────────────────── */
.center-toast-wrap {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.center-toast {
  background: #fff; border-radius: 20px;
  padding: 36px 56px; text-align: center;
  box-shadow: 0 12px 48px rgba(0,0,0,.22);
  opacity: 0; transform: scale(.85);
  transition: opacity .2s, transform .2s;
}
.center-toast.show { opacity: 1; transform: scale(1); }
.center-toast .ct-icon { font-size: 52px; line-height: 1; margin-bottom: 14px; }
.center-toast .ct-msg  { font-size: 20px; font-weight: 700; color: var(--gray-900); }

/* 「← 上一頁」返回鍵（common.js 注入，全站；佳樺 2026-09-19 要明顯一點） */
.app-back-btn { flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 12px 0 10px; margin-right: 8px; border: 1.5px solid #d6006e; border-radius: 999px; background: #fff; color: #d6006e; font-size: 13.5px; font-weight: 800; line-height: 1; cursor: pointer; white-space: nowrap; }
.app-back-btn .app-back-arrow { font-size: 17px; line-height: 1; }
.app-back-btn:hover { background: #fde7f1; }
.app-back-btn:active { background: #d6006e; color: #fff; }
.app-back-btn-floating { position: fixed; left: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 9999; height: 44px; padding: 0 16px 0 12px; background: #d6006e; color: #fff; border-color: #d6006e; font-size: 15px; box-shadow: 0 6px 18px rgba(214,0,110,.35); }
.app-back-btn-floating:hover { background: #b8005e; }
@media (max-width: 640px) { .app-back-btn .app-back-label { display: none; } .app-back-btn { padding: 0 9px; } .app-back-btn-floating .app-back-label { display: inline; } }

/* 老闆總覽的三張圖：桌機三欄、手機一欄 */
.dash-charts { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 900px) { .dash-charts { grid-template-columns: 1fr; } }

/* ❓ 每頁操作說明面板 */
.page-help { position: fixed; inset: 0; z-index: 10050; pointer-events: none; }
.page-help.open { pointer-events: auto; }
.page-help-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); opacity: 0; transition: opacity .18s; }
.page-help.open .page-help-backdrop { opacity: 1; }
.page-help-panel { position: absolute; top: 0; right: 0; height: 100%; width: min(440px, 92vw); background: #fff; box-shadow: -12px 0 40px rgba(0,0,0,.18); transform: translateX(100%); transition: transform .2s; overflow: auto; }
.page-help.open .page-help-panel { transform: none; }
.page-help-body { padding: 18px 20px 28px; font-size: 14px; line-height: 1.6; color: #1f2328; }
.page-help-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.page-help-kicker { font-size: 11.5px; letter-spacing: .08em; color: #9ca3af; font-weight: 700; }
.page-help-title { font-size: 18px; font-weight: 800; }
.page-help-x { border: 1px solid #e5e7eb; background: #fff; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; }
.page-help-draft { font-size: 12px; color: #b45309; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 6px 10px; margin: 6px 0 10px; }
.page-help-md h4 { font-size: 13.5px; margin: 16px 0 6px; padding-left: 8px; border-left: 3px solid #d6006e; }
.page-help-md p { margin: 6px 0; }
.page-help-md ul, .page-help-md ol { margin: 4px 0 8px; padding-left: 20px; }
.page-help-md li { margin: 3px 0; }
.page-help-foot { font-size: 11.5px; color: #9ca3af; margin-top: 16px; }
.page-help-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.page-help-edit label { display: block; font-size: 12px; font-weight: 700; color: #374151; margin: 10px 0 4px; }
.page-help-edit input, .page-help-edit textarea { width: 100%; padding: 7px 8px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; font-family: inherit; }
.page-help-edit .page-help-ok { font-weight: 500; }

/* ⓘ 即時提示（佳樺 2026-09-19：瀏覽器內建 title 要等一秒、字又小）；滑過立刻出現，手機點一下也會出現 */
.tip { position: relative; display: inline-block; cursor: help; color: #9ca3af; font-size: 11px; font-style: normal; }
.tip::after { content: attr(data-tip); position: absolute; left: 0; top: calc(100% + 6px); z-index: 80; min-width: 220px; max-width: 320px; white-space: normal; padding: 8px 10px; border-radius: 8px; background: #111827; color: #fff; font-size: 12.5px; font-weight: 500; line-height: 1.5; text-align: left; box-shadow: 0 8px 24px rgba(0,0,0,.25); opacity: 0; visibility: hidden; transition: opacity .08s; pointer-events: none; }
.tip::before { content: ""; position: absolute; left: 6px; top: calc(100% + 1px); border: 5px solid transparent; border-bottom-color: #111827; opacity: 0; visibility: hidden; }
.tip:hover::after, .tip:hover::before, .tip.on::after, .tip.on::before { opacity: 1; visibility: visible; }
.tip.tip-right::after { left: auto; right: 0; } .tip.tip-right::before { left: auto; right: 6px; }
.page-help-fig { display: block; margin: 8px 0 12px; border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; text-decoration: none; color: #6b7280; font-size: 11.5px; background: #f9fafb; }
.page-help-fig img { display: block; width: 100%; height: auto; }
.page-help-fig span { display: block; padding: 5px 8px; }
.page-help-panel { width: min(520px, 94vw); }

/* 鈴鐺裡的「手機通知」列（public/js/notify-ack.js） */
.notif-push-row { padding:8px 12px; font-size:12px; color:#444; background:#fafafa; border-bottom:1px solid #eee; line-height:1.6; }
.notif-sound-help { padding:6px 12px 8px; font-size:12px; color:#444; background:#fafafa; border-bottom:1px solid #eee; line-height:1.6; }
.notif-sound-help summary { cursor:pointer; color:#9d174d; font-weight:700; }
.notif-sound-help div { margin-top:4px; }
.notif-mini { border:1px solid #ccc; background:#fff; border-radius:12px; padding:1px 8px; font-size:11px; cursor:pointer; }
.notif-mini-on { background:#d6006e; color:#fff; border-color:#d6006e; font-weight:700; }

/* 寬表格的浮動左右捲軸（common.js tableScrollProxies）：Mac 預設捲軸會自動隱藏，
   自訂樣式後 Chrome 會一直顯示，才看得出「可以往右拉」（佳樺 2026-09-30） */
.table-hscroll::-webkit-scrollbar { height: 12px; }
.table-hscroll::-webkit-scrollbar-track { background: var(--gray-100, #f3f4f6); }
.table-hscroll::-webkit-scrollbar-thumb { background: #b8bcc4; border-radius: 6px; border: 2px solid var(--gray-100, #f3f4f6); }
.table-hscroll::-webkit-scrollbar-thumb:hover { background: #8f949c; }

/* 捲軸一律直接顯示（佳樺 2026-09-30：「把瀏覽器下方跟右方的 scroll bar 設定成直接顯現，不要等同事拉到底才出現；
   他們會放大畫面，要往下拉很久才看得到左右的 scroll bar」）。
   Mac 預設捲軸會自動隱藏，自訂樣式後 Chrome／Safari 會一直顯示。寬表格另外有浮動在視窗下緣的左右捲軸（common.js）。 */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: #f1f2f4; }
::-webkit-scrollbar-thumb { background: #b8bcc4; border-radius: 6px; border: 2px solid #f1f2f4; }
::-webkit-scrollbar-thumb:hover { background: #8f949c; }
::-webkit-scrollbar-corner { background: #f1f2f4; }
