/* 振佳空調管理系統 - 全域樣式 */
/* 從 index.html 拆分出來 (2026-08-08 v8) */
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", sans-serif;
    background: #f0f2f5;
    color: #1a1a1a;
    line-height: 1.5;
    padding-bottom: 70px;
  }
  /* 頂部 */
  .topbar {
    background: linear-gradient(135deg, #1e3a5f, #2d5a8e);
    color: #fff;
    padding: 14px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .topbar-row { display: flex; justify-content: space-between; align-items: center; }
  .topbar h1 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
  .topbar h1 .topbar-logo { width: 24px; height: 24px; border-radius: 50%; object-fit: contain; background: #fff; }
  .topbar .sub { font-size: 12px; opacity: 0.75; margin-top: 2px; }
  .top-actions { display: flex; gap: 8px; }
  .btn-ghost {
    background: rgba(255,255,255,0.15);
    border: 1.5px solid rgba(255,255,255,0.4);
    color: #fff;
    border-radius: 10px;
    padding: 7px 13px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
  }
  .btn-ghost:hover { background: rgba(255,255,255,0.28); }
  .search-box { margin-top: 10px; display: flex; gap: 8px; }
  .search-box input {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    outline: none;
  }
  .search-box input::placeholder { color: rgba(255,255,255,0.6); }
  .search-box input:focus { background: rgba(255,255,255,0.25); }

  /* 盤點提醒橫幅 */
  .reminder {
    background: #fff4e0;
    border-left: 5px solid #f59e0b;
    padding: 10px 16px;
    font-size: 13px;
    color: #92400e;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }
  .reminder button {
    background: #f59e0b;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
  }

  /* 底部導覽 */
  .bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    display: flex;
    z-index: 100;
  }
  .nav-item-wrap { position: relative; flex: 1; display: flex; justify-content: center; }
  .nav-item {
    flex: 1;
    max-width: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 9px 4px 8px;
    font-size: 11px;
    color: #888;
    cursor: pointer;
    border: none;
    background: none;
    transition: color 0.15s;
  }
  .nav-item .ic { font-size: 18px; display: block; line-height: 1.2; }
  .nav-item .label {
    display: block;
    font-size: 10.5px;
    font-weight: 600;
    color: #555;
    line-height: 1.2;
    white-space: nowrap;
  }
  .nav-item.active { color: #2d5a8e; }
  .nav-item.active .label { color: #2d5a8e; font-weight: 700; }
  .nav-item.active .ic { color: #2d5a8e; }
  .nav-item .badge {
    position: absolute;
    transform: translate(6px, -2px);
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    border-radius: 8px;
    padding: 0 5px;
    line-height: 15px;
  }
  .nav-item-wrap { position: relative; flex: 1; display: flex; justify-content: center; }

  /* 廠牌 tab */
  .brand-tabs {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 92px;
    z-index: 90;
    -webkit-overflow-scrolling: touch;
  }
  .brand-tab {
    flex-shrink: 0;
    padding: 6px 13px;
    border-radius: 20px;
    border: 1.5px solid #d0d0d0;
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: #555;
    white-space: nowrap;
    transition: all 0.15s;
  }
  .brand-tab .count {
    font-size: 11px;
    background: #eee;
    border-radius: 10px;
    padding: 1px 6px;
    margin-left: 4px;
    color: #888;
  }
  .brand-tab.active { background: #2d5a8e; border-color: #2d5a8e; color: #fff; }
  .brand-tab.active .count { background: rgba(255,255,255,0.25); color: #fff; }

  /* 內容區 */
  .content { padding: 14px 16px 20px; max-width: 640px; margin: 0 auto; }
  .section-title {
    font-size: 13px; font-weight: 700; color: #888;
    margin: 14px 0 8px;
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; user-select: none;
  }
  .section-title .loc { color: #2d5a8e; font-weight: 600; margin-right: auto; }
  /* 位置折疊按鈕（最左邊箭頭） */
  .section-title .collapse-btn {
    background: none; border: none; padding: 0 6px 0 0; margin: 0;
    font-size: 12px; color: #2d5a8e; cursor: pointer; line-height: 1;
    transition: transform .15s ease;
  }
  .section-title.collapsed .collapse-btn { transform: rotate(-90deg); }
  .loc-group.collapsed { display: none; }

  .item-card {
    background: #fff;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
  }
  .item-card .edit-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 11.5px;
    color: #2d5a8e;
    background: #eef4fa;
    border: 1px solid #cfe0f0;
    border-radius: 6px;
    padding: 2px 9px;
    cursor: pointer;
    z-index: 5;
    font-weight: 600;
    transition: all 0.15s;
  }
  .item-card .edit-btn:active { transform: scale(0.92); }
  /* v10.1：品項照片縮圖（點擊可看大圖） */
    .item-card .item-photo {
      width: 52px; height: 52px; object-fit: cover;
      border-radius: 8px; flex-shrink: 0;
      border: 1px solid #e3e8ef; background: #f7f9fc;
      cursor: zoom-in; transition: transform .12s;
    }
    .item-card .item-photo:hover { transform: scale(1.15); box-shadow: 0 2px 8px rgba(0,0,0,.18); }
    /* v10.1：大圖檢視 lightbox（全螢幕 overlay） */
    #photo-lightbox {
      position: fixed; inset: 0; z-index: 9999;
      background: rgba(15, 18, 28, .88);
      display: flex; align-items: center; justify-content: center;
      cursor: zoom-out; animation: lb-fade .15s ease;
    }
    #photo-lightbox .lightbox-content { position: relative; max-width: 94vw; max-height: 92vh; }
    #photo-lightbox img {
      max-width: 94vw; max-height: 92vh; object-fit: contain;
      border-radius: 10px; box-shadow: 0 8px 40px rgba(0,0,0,.5);
      cursor: default; background: #fff;
    }
    #photo-lightbox .lightbox-close {
      position: absolute; top: -38px; right: -4px;
      background: rgba(255,255,255,.15); color: #fff;
      width: 30px; height: 30px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-size: 16px; cursor: pointer;
    }
    #photo-lightbox .lightbox-close:hover { background: rgba(255,255,255,.32); }
    @keyframes fade { from { opacity: 0 } to { opacity: 1 } }
  /* v10.1：相似品項警示框（新增/編輯時浮出） */
  .similar-warn {
    margin-top: 8px; padding: 8px 10px; border-radius: 8px;
    background: #fff8e6; border: 1px solid #f0d48a;
    font-size: 12px; color: #8a6d1a; line-height: 1.6;
  }
  .similar-warn .sim-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .similar-warn .sim-row + .sim-row { margin-top: 4px; }
  .similar-warn a { color: #2d5a8e; font-weight: 600; text-decoration: none; flex-shrink: 0; }
  /* v10.1：編輯 modal 照片區塊 */
  .photo-box { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
  .photo-box img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid #e3e8ef; }
  .photo-box .photo-actions { display: flex; flex-direction: column; gap: 6px; }
  .item-info { flex: 1; min-width: 0; cursor: pointer; }
  .item-name { font-size: 14px; font-weight: 600; padding-right: 118px; }
  .item-name .edit-hint { font-size: 10px; color: #999; font-weight: 400; margin-left: 4px; }
  .site-badge {
    display: inline-block; font-size: 9.5px; font-weight: 600;
    background: #eef4fa; color: #2d5a8e;
    border-radius: 5px; padding: 1px 6px; margin-left: 6px;
    vertical-align: middle;
  }
  .site-badge.wh { background: #fff3e0; color: #e67e22; }
  .item-code { font-size: 11px; color: #999; margin-top: 1px; }
  .item-loc {
      font-size: 11px; color: #2d5a8e; background: #eef4fa;
      border-radius: 6px; padding: 2px 7px; display: inline-block; margin-top: 4px;
    }

  /* v10：編輯 modal 位置清單列 */
  .stock-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
  .stock-row .stock-loc { flex: 2; }
  .stock-row .stock-qty { flex: 1; min-width: 60px; }
  .stock-row .stock-note { flex: 2; }
  .stock-row .stock-del { flex-shrink: 0; padding: 6px 10px; font-size: 12px; }

  .qty-control { display: flex; align-items: center; flex-shrink: 0; }
  .qty-btn {
    width: 34px; height: 34px;
    border: none; border-radius: 9px;
    font-size: 18px; font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.1s;
  }
  .qty-btn:active { transform: scale(0.9); }
  .qty-minus { background: #fee2e2; color: #dc2626; }
  .qty-plus { background: #dcfce7; color: #16a34a; }
  .qty-btn:disabled { opacity: 0.35; cursor: not-allowed; }
  .qty-value {
    width: 46px; text-align: center;
    font-size: 15px; font-weight: 700;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
  }
  .qty-value .unit { font-size: 10px; color: #999; font-weight: 400; }

  /* 出庫按鈕 */
  .btn-out {
    background: #fff;
    border: 1.5px solid #f59e0b;
    color: #b45309;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 5px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: background 0.15s;
  }
  .btn-out:hover { background: #fff7ed; }
  .btn-prepare {
    background: #fff;
    border: 1.5px solid #7c3aed;
    color: #6d28d9;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 5px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: background 0.15s;
  }
  .btn-prepare:hover { background: #f5f3ff; }
  .prepared-tag {
    display: inline-block;
    background: #f5f3ff;
    color: #6d28d9;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    padding: 2px 8px;
    margin-top: 4px;
  }
  .kit-tag {
    display: inline-block;
    background: #ecfdf5;
    color: #047857;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    padding: 2px 8px;
    margin-top: 4px;
  }

  /* 儲存列 */
  .save-bar {
    position: fixed;
    bottom: 54px; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    padding: 10px 20px;
    display: none;
    justify-content: space-between;
    align-items: center;
    z-index: 95;
  }
  .save-bar.show { display: flex; }
  .save-bar .stat { font-size: 12px; color: #666; }
  .save-bar .stat b { font-size: 15px; color: #1a1a1a; }
  .btn-save {
    background: #2d5a8e; color: #fff; border: none;
    border-radius: 10px; padding: 10px 24px;
    font-size: 14px; font-weight: 700; cursor: pointer;
  }

  /* 表格（紀錄/盤點） */
  .data-table { width: 100%; background: #fff; border-radius: 12px; border: 1px solid #e5e7eb; overflow: hidden; }
  .data-table th {
    background: #f8fafc;
    text-align: left;
    padding: 9px 10px;
    font-size: 11.5px;
    color: #666;
    font-weight: 700;
    border-bottom: 1.5px solid #e5e7eb;
  }
  .data-table td {
    padding: 9px 10px;
    font-size: 12.5px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
  }
  .data-table tr:last-child td { border-bottom: none; }
  .dest-chip {
    background: #fff7ed;
    color: #b45309;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11.5px;
    font-weight: 600;
  }
  .qty-neg { color: #dc2626; font-weight: 700; }
  .qty-pos { color: #16a34a; font-weight: 700; }
  .diff-zero { color: #999; }
  .diff-pos { color: #16a34a; font-weight: 700; }
  .diff-neg { color: #dc2626; font-weight: 700; }

  /* 盤點輸入 */
  .count-row { display: flex; align-items: center; gap: 8px; }
  .count-row input {
    width: 70px;
    padding: 6px 8px;
    border: 1.5px solid #d0d5dd;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    outline: none;
  }
  .count-row input:focus { border-color: #2d5a8e; }
  .count-row input.changed { border-color: #f59e0b; background: #fff7ed; }

  .stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }
  .stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 12px 6px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  }
  .stat-card .num { font-size: 20px; font-weight: 800; color: #1e3a5f; }
  .stat-card .lbl { font-size: 11px; color: #888; margin-top: 2px; }
  .stat-card.warn .num { color: #f59e0b; }
  .stat-card.danger .num { color: #dc2626; }
  .stat-card.clickable { cursor: pointer; transition: transform 0.1s, box-shadow 0.1s; }
  .stat-card.clickable:active { transform: scale(0.95); box-shadow: 0 0 0 2px #2d5a8e33; }

  .empty { text-align: center; color: #999; padding: 40px 0; font-size: 14px; }

  .toast {
    position: fixed; top: 60px; left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #333; color: #fff;
    padding: 8px 18px; border-radius: 20px;
    font-size: 13px; opacity: 0;
    transition: all 0.3s; z-index: 300; pointer-events: none;
    max-width: 85%; text-align: center;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  .toast.success { background: #16a34a; }
  .toast.error { background: #dc2626; }

  /* Modal */
  .modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    z-index: 200; display: none; align-items: flex-end; justify-content: center;
  }
  .modal-overlay.show { display: flex; }
  .modal {
    background: #fff; width: 100%; max-width: 520px;
    border-radius: 16px 16px 0 0;
    padding: 20px;
    max-height: 88vh; overflow-y: auto;
  }
  .modal h3 { font-size: 17px; margin-bottom: 14px; color: #1e3a5f; }
  .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
  .modal-header h3 { margin-bottom: 0; }
  .modal-close {
    background: #f0f2f5; border: 1px solid #e2e6ec; color: #555;
    border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
  }
  .modal-close:hover { background: #e4e8ee; color: #1a1a1a; }
  .form-row { margin-bottom: 12px; }
  .form-row label { display: block; font-size: 12.5px; font-weight: 600; color: #666; margin-bottom: 4px; }
  .form-row input, .form-row select, .form-row textarea {
    width: 100%; padding: 9px 12px;
    border: 1.5px solid #d0d5dd; border-radius: 8px;
    font-size: 14px; outline: none;
  }
  .form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: #2d5a8e; }
  .form-row textarea { resize: vertical; min-height: 50px; }
  /* 可搜尋材料選擇（整組 Modal） */
  .kit-empty { font-size: 12.5px; color: #999; padding: 4px 0 8px; }
  .kit-comp-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: flex-start; }
  .kit-search { position: relative; flex: 1; min-width: 0; }
  .kit-search-input {
    width: 100%; height: 40px; padding: 0 30px 0 10px;
    border: 1.5px solid #d0d5dd; border-radius: 8px;
    font-size: 13.5px; outline: none; background: #fff;
  }
  .kit-search-input:focus { border-color: #1890FF; box-shadow: 0 0 0 3px rgba(24,144,255,0.12); }
  .kit-sel-info { font-size: 11px; color: #16a34a; font-weight: 600; padding: 2px 0 0 2px; }
  .kit-caret {
      position: absolute; right: 9px; top: 20px; transform: translateY(-50%);
      font-size: 11px; color: #94a3b8; pointer-events: none;
    }
  .kit-dropdown {
    display: none; position: absolute; left: 0; right: 0; top: calc(100% + 3px);
    background: #fff; border: 1.5px solid #d0d5dd; border-radius: 8px;
    box-shadow: 0 10px 26px rgba(0,0,0,0.14);
    max-height: 240px; overflow-y: auto; z-index: 60;
  }
  .kit-dropdown.open { display: block; }
  .kit-drop-opt {
    padding: 9px 10px; cursor: pointer; display: flex;
    justify-content: space-between; align-items: center; gap: 8px;
    border-bottom: 1px solid #f2f4f8;
  }
  .kit-drop-opt:active { background: #e8f2ff; }
  .kit-drop-opt .nm { font-size: 13px; color: #1a1a1a; }
  .kit-drop-opt .bd { font-size: 11px; color: #888; margin-top: 1px; }
  .kit-drop-opt .stk { flex: none; font-size: 12px; color: #16a34a; font-weight: 700; white-space: nowrap; }
  .kit-drop-empty { padding: 12px 10px; font-size: 12.5px; color: #999; text-align: center; }
  .kit-qty {
    width: 62px; flex: none; height: 40px; text-align: center;
    border: 1.5px solid #d0d5dd; border-radius: 8px; font-size: 13.5px; outline: none;
  }
  .kit-rm { flex: none; width: 40px; height: 40px; padding: 0 !important; }

  /* ===== 新增整組・材料選擇（demo 樣式移植：selected-row / mat-search / btn-add-row） ===== */
  .kit-empty { font-size: 12.5px; color: #94a3b8; padding: 4px 0 8px; }
  .selected-row {
    display: flex; align-items: center; gap: 8px;
    background: #f4f7fb; border: 1px solid #e2e8f0; border-radius: 10px;
    padding: 9px 12px; margin-bottom: 8px;
  }
  .selected-row .info { flex: 1; min-width: 0; }
  .selected-row .info .nm {
    font-size: 13.5px; font-weight: 600; color: #16283f;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .selected-row .info .bd { font-size: 11.5px; color: #6b7a90; }
  .selected-row input[type="number"] {
    width: 58px; height: 36px; text-align: center;
    border: 1.5px solid #d8dee9; border-radius: 8px; font-size: 14px; outline: none;
  }
  .selected-row .rm {
    width: 28px; height: 28px; border: none; background: #fee2e2; color: #dc2626;
    border-radius: 8px; font-size: 13px; cursor: pointer; flex: none;
  }
  .mat-search { position: relative; }
  .mat-search .input-wrap { position: relative; }
  .mat-search input {
    width: 100%; height: 46px; padding: 0 34px 0 12px;
    border: 1.5px solid #d8dee9; border-radius: 10px;
    font-size: 14px; background: #fafbfc; outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .mat-search input:focus { border-color: #1890FF; box-shadow: 0 0 0 3px rgba(24,144,255,0.18); }
  .mat-search .caret {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    font-size: 12px; color: #94a3b8; pointer-events: none;
  }
  .btn-add-row {
    width: 100%; height: 42px; margin-top: 2px;
    background: #fff; border: 1.5px dashed #1890FF; color: #1890FF;
    border-radius: 10px; font-size: 13.5px; font-weight: 700; cursor: pointer;
  }
  .btn-add-row:hover { background: #f0f7ff; }
  #kit-modal .btn-confirm { background: linear-gradient(135deg, #1890FF, #36a3ff); }
  .form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .modal-actions { display: flex; gap: 10px; margin-top: 16px; }
  .modal-actions button { flex: 1; padding: 11px; border-radius: 10px; font-size: 14px; font-weight: 700; cursor: pointer; border: none; }
  .btn-cancel { background: #f0f0f0; color: #555; }
  .btn-confirm { background: #2d5a8e; color: #fff; }
  .btn-confirm.orange { background: #f59e0b; }

  .loading { text-align: center; padding: 60px 0; color: #888; }
  .loading .spin {
    width: 36px; height: 36px;
    border: 4px solid #e0e0e0; border-top-color: #2d5a8e;
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 0.8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ===== 分片切換（辦公室 / 倉庫） ===== */
  .site-tabs {
    display: flex;
    gap: 8px;
    background: rgba(255,255,255,0.14);
    border-radius: 12px;
    padding: 4px;
    margin-top: 12px;
  }
  .site-tab {
    flex: 1;
    padding: 8px 0;
    border: none;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: rgba(255,255,255,0.75);
    transition: all 0.2s;
    line-height: 1.3;
  }
  .site-tab.active {
    background: #fff;
    color: #1e3a5f;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  }
  .site-tab .sub { display: block; font-size: 10.5px; font-weight: 400; opacity: 0.7; margin-top: 1px; }
  .site-tab.active .sub { opacity: 0.85; }

  @media (min-width: 768px) {
    .content { max-width: 900px; }
    .item-card { padding: 14px 18px; }
    .modal { border-radius: 16px; margin-bottom: 20px; }
    .modal-overlay { align-items: center; }
  }

/* v11 登入：topbar 使用者選單 */
.top-actions { align-items: center; }
.user-menu { display: flex; align-items: center; gap: 8px; margin-left: 6px; }
.user-chip {
  font-size: 13px; font-weight: 700; color: #fff;
  background: rgba(255,255,255,0.12);
  padding: 5px 10px; border-radius: 20px; white-space: nowrap;
}
.admin-badge {
  font-size: 10.5px; font-weight: 800; color: #ffd76a;
  background: rgba(255,215,106,0.15);
  padding: 1px 7px; border-radius: 10px; margin-left: 3px;
}

/* v15 使用者管理 modal：角色 badge（權限一覽用） */
.role-badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 700; line-height: 1.5; white-space: nowrap;
}
.role-badge-admin  { background: #eef2ff; color: #4f46e5; }
.role-badge-user   { background: #ecfdf5; color: #059669; }
.role-badge-viewer { background: #f1f5f9; color: #6b7280; }
.perm-btn {
  display: inline-block; margin-top: 4px; border: none; border-radius: 7px;
  padding: 3px 8px; font-size: 11px; cursor: pointer; white-space: nowrap;
  background: #eff8ff; color: #1890ff;
}
.perm-btn:hover { background: #d6edff; }
.perm-detail-row td { background: #f8fafc; padding: 8px 10px; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px; font-size: 11.5px; }
.perm-ok { color: #16a34a; }
.perm-no { color: #94a3b8; }

/* v11 使用者管理 modal：新增列（class 化，支援手機換行） */
.create-row { display: flex; gap: 8px; margin-bottom: 14px; }
.create-row .cr-input {
  flex: 1; min-width: 0;
  padding: 8px; border: 1px solid #d8dee9; border-radius: 8px; font-size: 13px;
}
.create-row .cr-input:focus { outline: none; border-color: #2d5a8e; }
.create-row .cr-btn { flex: 1; }

/* 使用者表格操作欄：桌面一行、手機垂直堆疊（按鈕文字完整顯示） */
.user-actions { padding: 8px; text-align: right; white-space: nowrap; }
.user-actions .btn-ghost {
  font-size: 12px; margin-left: 4px;
  color: #1a1a1a;                       /* 黑字（白底 modal 上看得清楚） */
  background: #fff;
  border: 1.2px solid #d8dee9;
}
.user-actions .btn-ghost:hover { background: #f3f5f8; }
.user-actions .btn-ghost.danger { color: #dc2626; border-color: #fecaca; }
@media (max-width: 767px) {
  .user-actions { display: flex; flex-direction: column; align-items: stretch; gap: 5px; text-align: left; }
  .user-actions .btn-ghost { margin-left: 0; }
  /* 手機：使用者表格卡片化（每列一張卡，操作按鈕完整顯示） */
  .users-table thead { display: none; }
  .users-table, .users-table tbody, .users-table tr, .users-table td { display: block; width: 100%; }
  .users-table tr {
    background: #f7f9fb; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
    border: 1px solid #edf0f4;
  }
  .users-table td { padding: 3px 0; border: none; text-align: left !important; }
  .users-table td:first-child { font-size: 14px; }
  .user-actions { flex-direction: row; flex-wrap: wrap; padding-top: 6px; }
  .user-actions .btn-ghost { flex: 1 1 auto; white-space: nowrap; }
}

/* 手機版（<768px）：topbar 換行 + 登出/使用者 icon-only + modal 新增列 2×2 */
@media (max-width: 767px) {
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .user-menu { margin-left: 0; }
  .admin-badge { display: none; }               /* 消除「管理員」重複顯示 */
  .logout-text, .users-text { display: none; }  /* 登出/使用者 icon-only */
  .create-row { flex-wrap: wrap; }
  .create-row .cr-input { flex: 1 1 45%; }
  .create-row .cr-btn { flex: 1 1 100%; }
}

/* ===== v1.1 已領出照片欄 + 整組材料型號（2026-08-11 Sarah 需求） ===== */
.data-table .photo-cell { width: 54px; padding: 6px; }
.so-photo { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; display: block; cursor: zoom-in; transition: transform .12s; }
.so-photo:hover { transform: scale(1.15); box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.so-photo-empty { display: flex; align-items: center; justify-content: center; background: #eef2f7; color: #b6c2cf; font-size: 18px; }
.selected-row .info .bd .model,
.kit-drop-opt .bd .model { color: #1890FF; font-weight: 600; }

/* ===== v1.1 庫存頁 卡片 ✕ 刪除材料（2026-08-11 Sarah 需求） ===== */
  .item-card .del-btn {
    position: absolute;
    top: 8px;
    right: 66px;
    font-size: 11.5px;
    color: #d33;
    background: #fff;
    border: 1px solid #f3c1c1;
    border-radius: 6px;
    padding: 2px 9px;
    cursor: pointer;
    z-index: 5;
    font-weight: 600;
    transition: all 0.15s;
  }
  .item-card .del-btn:hover { background: #fee2e2; }
  .item-card .del-btn:active { transform: scale(0.92); }

  /* ===== v1.1 通用 編輯/刪除 按鈕（整組/待領出/已領出，2026-08-11 Sarah） ===== */
  .btn-edit {
    background: #fff; border: 1.5px solid #2d5a8e; color: #2d5a8e;
    border-radius: 8px; padding: 5px 10px; font-size: 11.5px; font-weight: 700;
    cursor: pointer; margin-top: 5px; display: inline-flex; align-items: center; gap: 3px;
    transition: background 0.15s;
  }
  .btn-edit:hover { background: #eef4fa; }
  .btn-del {
    background: #fff; border: 1.5px solid #dc2626; color: #dc2626;
    border-radius: 8px; padding: 5px 10px; font-size: 11.5px; font-weight: 700;
    cursor: pointer; margin-top: 5px; display: inline-flex; align-items: center; gap: 3px;
    transition: background 0.15s;
  }
  .btn-del:hover { background: #fee2e2; }
  .btn-del:active { transform: scale(0.96); }

/* v11.2 修改密碼 modal：密碼強度即時打勾 + 確認不一致警示 */
.pw-checks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pw-check { font-size: 11px; color: #888; background: #f0f2f5; border-radius: 12px; padding: 3px 8px; display: inline-block; }
.pw-check.ok { color: #15803d; background: #dcfce7; }
.cpw-mismatch { font-size: 11px; color: #b45309; background: #fef3c7; padding: 6px 10px; border-radius: 6px; margin-top: 6px; }

/* v11.2 改密碼 modal：取消按鈕 ghost 樣式（與儲存並排） */
.btn-cancel-ghost {
  background: #f0f2f5; border: none; color: #555;
  border-radius: 8px; padding: 11px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-cancel-ghost:hover { background: #e5e8ec; color: #1e3a5f; }

/* ☰ 按鈕：桌面隱藏（手機 media query 顯示） */
@media (min-width: 768px) { #btn-menu { display: none; } }

/* ===== v1.2 手機版卡片式 UI + ⋯ 動作選單（2026-08-11 家豪需求） ===== */

/* ---------- ⋯ 更多按鈕（卡片右上角） ---------- */
.more-btn {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px;
  border-radius: 50%; border: none; background: #f0f2f5; color: #4b5563;
  font-size: 17px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 5;
  transition: background .12s;
}
.more-btn:active { background: #e0e4ea; }

/* ---------- Bottom Sheet 動作選單（點 ⋯ 彈出） ---------- */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(15,18,28,.45); z-index: 3000;
  display: none; align-items: flex-end; justify-content: center;
}
.sheet-overlay.show { display: flex; }
.sheet {
  width: 100%; max-width: 560px; background: #fff;
  border-radius: 16px 16px 0 0; padding: 10px 12px 18px;
  animation: sheet-up .18s ease;
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet .sheet-title { font-size: 12px; color: #9ca3af; text-align: center; padding: 4px 0 8px; font-weight: 600; }
.sheet .s-item {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-radius: 10px;
  font-size: 14px; font-weight: 600; color: #111827; cursor: pointer;
}
.sheet .s-item:active { background: #f5f7fa; }
.sheet .s-item .ic { font-size: 16px; width: 22px; text-align: center; }
.sheet .s-item.out { color: #2d5a8e; }
.sheet .s-item.back { color: #b45309; }
.sheet .s-item.del { color: #dc2626; }
.sheet .s-divider { height: 6px; background: #f3f4f6; border-radius: 4px; margin: 4px 0; }
.sheet .s-cancel {
  display: block; width: 100%; padding: 13px; border: none; background: none;
  font-size: 14px; font-weight: 600; color: #6b7280; cursor: pointer;
  border-top: 1px solid #f3f4f6; margin-top: 6px; border-radius: 10px;
}

/* ---------- 手機版卡片（render 手機模板輸出） ---------- */
.m-card {
  background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.07);
  margin-bottom: 10px; overflow: hidden; border: 1px solid #f0f2f5; position: relative;
}
.m-card .card-main { display: flex; gap: 10px; padding: 10px 12px; align-items: center; }
.m-card .thumb {
  width: 58px; height: 58px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
  background: #eef2f7; display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #b6c2cf; cursor: zoom-in; border: 1px solid #eef0f3;
}
.m-card .thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.m-card .info { flex: 1; min-width: 0; padding-right: 30px; }
.m-card .nm { font-size: 13.5px; font-weight: 600; color: #111827; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-card .sub { font-size: 11px; color: #6b7280; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-card .loc-tag {
  display: inline-block; font-size: 10.5px; color: #2d5a8e; background: #eef4fa;
  border: 1px solid #cfe0f0; border-radius: 6px; padding: 1px 7px; margin-top: 4px;
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.m-card .qty-col { text-align: center; flex-shrink: 0; padding-right: 34px; }
.m-card .qty-num { font-size: 17px; font-weight: 700; color: #111827; line-height: 1.1; }
.m-card .qty-unit { font-size: 10px; color: #9ca3af; display: block; }
.m-card .qty-neg { color: #dc2626; }
.m-card .qty-violet { color: #6d28d9; }
.m-card .qty-actions { display: flex; border-top: 1px solid #f3f4f6; background: #fafbfc; }
.m-card .qty-actions .act {
  flex: 1; border: none; background: none; padding: 10px 2px; font-size: 13px; font-weight: 700;
  cursor: pointer; color: #374151; border-right: 1px solid #f0f2f5;
}
.m-card .qty-actions .act:last-child { border-right: none; }
.m-card .qty-actions .act.mn { color: #dc2626; }
.m-card .qty-actions .act.pl { color: #16a34a; }
.m-card .qty-actions .act:disabled { color: #c4cbd4; }
.m-card .qty-actions .act.mid {
  display: flex; align-items: center; justify-content: center; gap: 3px;
  font-size: 14px; font-weight: 700; color: #111827; cursor: pointer;
}
.m-card .qty-actions .act.mid .unit { font-size: 10px; color: #999; font-weight: 400; }
.m-card .chip { display: inline-block; font-size: 10px; font-weight: 600; border-radius: 20px; padding: 1px 8px; margin-left: 4px; }
.m-card .chip.green { background: #dcfce7; color: #15803d; }
.m-card.reverted { opacity: .55; }
.m-card .reverted-tag { font-size: 10px; color: #9ca3af; margin-left: 4px; }

/* 手機庫存卡：底部 待領出/已領出 按鈕列（還原顯示） */
.m-card-actions {
  display: flex; gap: 8px; padding: 0 12px 12px;
}
.m-card-actions .btn-prepare, .m-card-actions .btn-out {
  flex: 1; margin: 0 !important; padding: 10px 4px !important; font-size: 12.5px;
  border-radius: 9px;
}

/* 整組卡（手機） */
.m-card .kit-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 4px; padding-right: 44px; }

.m-card .kit-name { font-size: 13.5px; font-weight: 700; color: #111827; }
.m-card .kit-stock { font-size: 11px; color: #2d5a8e; background: #eef4fa; border-radius: 6px; padding: 2px 8px; font-weight: 600; }
.m-card .kit-comps { padding: 6px 12px 10px; }
.m-card .kit-comp .cphoto { width: 34px; height: 34px; border-radius: 6px; overflow: hidden; flex-shrink: 0; background: #f0f2f5; display: flex; align-items: center; justify-content: center; }
.m-card .kit-comp .cphoto img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.m-card .kit-comp .cphoto .cphoto-empty { font-size: 14px; }
.data-table .cphoto { width: 34px; height: 34px; border-radius: 6px; overflow: hidden; display: inline-flex; vertical-align: middle; margin-right: 8px; background: #f0f2f5; align-items: center; justify-content: center; }
.data-table .cphoto img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.data-table .cphoto .cphoto-empty { font-size: 14px; }
.m-card .kit-comp { display: flex; justify-content: flex-start; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dashed #f0f2f5; font-size: 11.5px; }
.m-card .kit-comp:last-child { border-bottom: none; }
.m-card .kit-comp .cname { color: #374151; white-space: normal; overflow: hidden; text-overflow: ellipsis; max-width: 170px; line-height: 1.4; }
.m-card .kit-comp .cneed { color: #6b7280; flex-shrink: 0; margin-left: auto; }
.m-card .kit-comp .cneed b { color: #111827; }
.m-card .kit-comp .cneed b.ok { color: #16a34a; }
.m-card .kit-comp .cneed b.low { color: #dc2626; }

/* ---------- 手機版（<768px） ---------- */
@media (max-width: 767px) {
  /* topbar 手機版：保留 👤 使用者 chip；匯出/改密碼/使用者/登出 按鈕收進 ☰ */
  .top-actions .btn-ghost { display: none; }
  .user-menu .btn-ghost { display: none; }
  .user-menu { display: flex !important; }
  .topbar .sub { display: none; }
  /* 手機 ☰ 按鈕（index.html 內建，桌面隱藏） */
  #btn-menu { display: flex; }

  /* topbar + 搜尋 + 分頁 固定頂部（sticky） */
  .topbar { position: sticky; top: 0; z-index: 900; }

  /* 內容區留給底部導覽 */
  .content { padding-bottom: 92px; }

  /* 注意：盤點頁仍用 data-table（手機不修改），故不隱藏 table */

  /* 手機庫存卡：qty-control 縮小（配合 qty-col padding-right 避開 ⋯） */
  .m-card .qty-control .qty-btn { width: 30px; height: 30px; font-size: 16px; border-radius: 8px; }
  .m-card .qty-control .qty-value { width: 40px; font-size: 14px; }
}


/* ========== 行事曆派工（📅） ========== */
.cal-wrap { display: flex; flex-direction: column; gap: 14px; }
/* 桌面：月曆與派工明細左右並排（家豪 2026-08-12 指定，同 demo 桌面版） */
@media (min-width: 768px) {
  .cal-wrap { display: grid; grid-template-columns: 1.15fr 1fr; align-items: start; }
  .cal-toolbar { grid-column: 1 / -1; }
  .cal-reminder { grid-column: 1 / -1; }
}
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: linear-gradient(135deg, #1e3a5f, #2d5a8e); border-radius: 12px; padding: 12px 14px; }
.cal-toolbar-mid { flex: 1; text-align: center; }
.cal-title { font-size: 17px; font-weight: 700; color: #fff; }
.cal-sub { font-size: 12.5px; color: rgba(255,255,255,.85); margin-top: 2px; }
.cal-tb-btn { background: rgba(255,255,255,.18); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.cal-tb-btn:hover { background: rgba(255,255,255,.3); }
.cal-tb-btn-primary { background: #fff; color: #1e3a5f; }
.cal-tb-btn-primary:hover { background: #f0f4f8; }
.btn-sm { background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; padding: 6px 12px; font-size: 12.5px; font-weight: 700; cursor: pointer; color: #333; }
.btn-sm.btn-primary { background: #2d5a8e; border-color: #2d5a8e; color: #fff; }
.cal-card { padding: 16px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.cal-month-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.cal-month-header h3 { margin: 0; font-size: 17px; color: #2d5a8e; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-weekday { text-align: center; padding: 6px 0; font-weight: 700; font-size: 12px; color: #888; }
.cal-cell { background: #fafbfc; border: 1px solid #f0f0f0; border-radius: 8px; min-height: 64px; padding: 4px; cursor: pointer; position: relative; }
.cal-cell:hover { border-color: #1a73e8; }
.cal-cell.cal-other { background: #f7f7f7; color: #ccc; }
.cal-cell.cal-today { border: 2px solid #1a73e8; }
.cal-cell.cal-today .cal-day-num { background: #1a73e8; color: #fff; }
.cal-cell.cal-selected { background: #e8f0fe; }
.cal-day-num { font-weight: 700; font-size: 12px; color: #555; display: inline-block; min-width: 20px; text-align: center; border-radius: 50%; }
.cal-other .cal-day-num { color: #ccc; }
.cal-evt { display: block; font-size: 10px; padding: 1px 4px; border-radius: 4px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.cal-evt-more { background: #444; }
.cal-day-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; font-weight: 700; font-size: 15px; color: #2d5a8e; }
.cal-timeline { position: relative; margin-left: 8px; padding-left: 14px; border-left: 3px solid #e0e0e0; }
.cal-tl-row { position: relative; margin-bottom: 10px; }
.cal-tl-dot { position: absolute; left: -14px; top: 14px; width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 3px solid #333; }
.cal-event-card { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 9px 10px; position: relative; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.cal-creator { display: flex; justify-content: space-between; align-items: center; background: #f8fafc; border-bottom: 1px dashed #e2e8f0; margin: -9px -10px 7px; padding: 4px 10px; border-radius: 8px 8px 0 0; font-size: 10.5px; color: #64748b; }
.cal-card-actions { position: absolute; right: 8px; top: 25px; }
.btn-card { background: none; border: none; cursor: pointer; font-size: 12px; padding: 2px 4px; }
.btn-card.btn-edit { color: #1a73e8; }
.btn-card.btn-delete { color: #999; }
.cal-time { font-weight: 700; font-size: 12px; color: #2d5a8e; }
.cal-client { font-weight: 700; margin: 2px 0; font-size: 13px; }
.cal-addr { font-size: 11.5px; color: #777; }
.cal-note { font-size: 11.5px; color: #777; }
.cal-who { font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; }
.cal-who-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.cal-conflict { background: #ffe6e6; color: #d93025; border: 1px solid #ffb3b3; border-radius: 6px; padding: 8px 10px; font-size: 12.5px; margin-bottom: 12px; display: none; }
.cal-person-list { display: flex; flex-direction: column; gap: 6px; }
.cal-person-opt { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid #e5e7eb; border-radius: 8px; cursor: pointer; font-size: 13px; }
.cal-person-opt input { width: auto; }
.cal-swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.cal-set-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.cal-set-tab { padding: 6px 14px; border: 1px solid #cbd5e1; background: #fff; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; color: #555; }
.cal-set-tab.active { background: #2d5a8e; color: #fff; border-color: #2d5a8e; }
.cal-set-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cal-set-table th, .cal-set-table td { border: 1px solid #e5e7eb; padding: 6px 8px; text-align: left; }
.cal-set-table th { background: #f1f5f9; }
.cal-add-row { display: flex; gap: 8px; margin-top: 10px; }
.cal-add-row input { flex: 1; }
.cal-hint { font-size: 11.5px; color: #94a3b8; margin-top: 8px; }
.cal-color-dots { display: flex; gap: 4px; flex-wrap: wrap; }
.cal-color-dots span { width: 18px; height: 18px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.cal-color-dots span.sel { border-color: #111; }
.cal-off { color: #94a3b8; font-size: 12px; }
/* 啟用開關（行事曆設定用） */
.switch { width: 38px; height: 20px; border-radius: 10px; background: #cbd5e1; border: none; cursor: pointer; position: relative; padding: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: #22c55e; }
.switch.on::after { left: 20px; }
@media (max-width: 767px) {
  .cal-cell { min-height: 58px; }
  .cal-evt { font-size: 9.5px; }
}

/* 今日提醒條（demo 同款） */
.cal-reminder { background: #e8f0fe; border-left: 5px solid #1a73e8; padding: 10px 16px; font-size: 13px; color: #174ea6; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-radius: 8px; }
.cal-reminder button { background: #1a73e8; color: #fff; border: none; border-radius: 8px; padding: 6px 14px; font-size: 12.5px; font-weight: 700; cursor: pointer; flex-shrink: 0; }
@media (max-width: 767px) {
  .cal-reminder { font-size: 12px; flex-direction: column; align-items: stretch; text-align: center; }
}
