/* ===========================================================
   theme.css —— 界面样式（白底 + 青色主色）
   主色 #00B0B8 取自 Logo 的标准色
   =========================================================== */

:root {
  --brand: #00b0b8;          /* 主色·青色 */
  --brand-dark: #009099;     /* 深青：hover 状态 */
  --brand-light: #e0f7f8;    /* 浅青：选中背景 */
  --brand-lighter: #f2fbfb;  /* 极浅青：区块背景 */

  --text: #1f2937;           /* 主文字 */
  --text-2: #6b7280;         /* 次要文字 */
  --text-3: #9ca3af;         /* 提示文字 */

  --line: #e5e7eb;           /* 边框 */
  --bg: #f7f8fa;             /* 页面底色 */
  --white: #ffffff;

  --danger: #e24b4a;
  --warning: #ef9f27;
  --success: #10b981;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

/* ============== 登录页 ============== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e0f7f8 0%, #f7f8fa 60%, #fff 100%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border-radius: 16px;
  padding: 40px 36px 32px;
  box-shadow: 0 8px 32px rgba(0, 176, 184, .12);
  text-align: center;
}

.login-card img.logo { width: 120px; height: auto; margin-bottom: 8px; }
.login-card h1 { font-size: 20px; font-weight: 600; margin: 12px 0 4px; }
.login-card .sub { font-size: 13px; color: var(--text-2); margin-bottom: 28px; }

.field { margin-bottom: 16px; text-align: left; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }

.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: var(--white);
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}

.btn {
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all .15s;
  background: var(--white);
}

.btn-primary { background: var(--brand); color: #fff; width: 100%; padding: 12px; font-size: 15px; font-weight: 500; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { background: #9edfe2; cursor: not-allowed; }

.btn-line { border-color: var(--line); color: var(--text); }
.btn-line:hover { border-color: var(--brand); color: var(--brand); }

.btn-danger { border-color: #f3c6c6; color: var(--danger); }
.btn-danger:hover { background: #fdf0f0; border-color: var(--danger); }

.btn-sm { padding: 5px 12px; font-size: 13px; }

.btn-ghost { background: transparent; color: var(--brand); padding: 6px 10px; }
.btn-ghost:hover { background: var(--brand-light); }

.msg { padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.msg-error { background: #fdf0f0; color: var(--danger); border: 1px solid #f3c6c6; }
.msg-ok { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.msg-info { background: var(--brand-lighter); color: var(--brand-dark); border: 1px solid #b5e5e7; }

.hint { font-size: 12px; color: var(--text-3); text-align: center; margin-top: 18px; line-height: 1.7; }

/* ============== 主框架 ============== */
.app { display: none; min-height: 100vh; }
.app.show { display: block; }

.topbar {
  height: 56px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar img.logo { height: 30px; width: auto; }
.topbar .divider { width: 1px; height: 22px; background: var(--line); }

.nav { display: flex; gap: 4px; }

.nav-item {
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 14px;
  transition: all .15s;
}

.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 500; }

.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar .who { font-size: 13px; color: var(--text-2); }
.topbar .who b { color: var(--text); font-weight: 500; }

.tag-role {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--brand-light);
  color: var(--brand-dark);
  margin-left: 6px;
}

.tag-role.admin { background: #fef3e2; color: #b45309; }

.container { max-width: 1440px; margin: 0 auto; padding: 22px 24px 60px; }

/* ============== 汇总卡片 ============== */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.card .label { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.card .num { font-size: 28px; font-weight: 600; line-height: 1.2; }
.card .num small { font-size: 14px; font-weight: 400; color: var(--text-2); margin-left: 4px; }
.card.hl { border-color: var(--brand); background: var(--brand-lighter); }
.card.hl .num { color: var(--brand-dark); }

/* ============== 工具栏 ============== */
.toolbar {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}

.toolbar input[type=text], .toolbar input[type=date] {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.toolbar input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.toolbar input[type=text] { width: 260px; }
.toolbar .spacer { flex: 1; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); }

/* ============== 表格 ============== */
.table-box {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }

th {
  background: #fafbfc;
  text-align: left;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td { padding: 12px 14px; border-bottom: 1px solid #f1f2f4; font-size: 14px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--brand-lighter); }

.num-cell { font-variant-numeric: tabular-nums; }
.money { font-weight: 500; color: var(--text); }
.en { color: var(--text-2); font-size: 13px; }

.act { display: flex; gap: 4px; white-space: nowrap; }

.empty { padding: 56px 20px; text-align: center; color: var(--text-3); }
.empty .big { font-size: 15px; margin-bottom: 6px; color: var(--text-2); }

.pager { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); }
.pager .info { font-size: 13px; color: var(--text-2); }

/* ============== 弹窗 ============== */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 100;
}

.mask.show { display: flex; }

.modal {
  background: var(--white);
  border-radius: 14px;
  width: 100%;
  max-width: 720px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
  margin: auto 0;
}

.modal-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
}

.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-head .x { margin-left: auto; cursor: pointer; color: var(--text-3); font-size: 22px; line-height: 1; padding: 0 4px; }
.modal-head .x:hover { color: var(--text); }

.modal-body { padding: 22px 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ============== 表单 ============== */
.group-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--brand-dark);
  padding: 4px 0 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.group-title::before {
  content: '';
  width: 3px;
  height: 13px;
  background: var(--brand);
  border-radius: 2px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 22px; }
.form-grid .full { grid-column: 1 / -1; }

.form-item label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.form-item label .req { color: var(--danger); margin-left: 2px; }

.form-item input, .form-item select, .form-item textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.form-item input:focus, .form-item select:focus, .form-item textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}

.form-item.err input { border-color: var(--danger); }
.form-item .err-tip { font-size: 12px; color: var(--danger); margin-top: 5px; display: none; }
.form-item.err .err-tip { display: block; }

/* 费用自动计算区 */
.calc-bar {
  background: var(--brand-lighter);
  border: 1px solid #b5e5e7;
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.calc-bar .lb { font-size: 13px; color: var(--brand-dark); }
.calc-bar .formula { font-size: 13px; color: var(--text-2); }
.calc-bar .formula b { color: var(--text); font-weight: 500; }
.calc-bar .result { margin-left: auto; font-size: 26px; font-weight: 600; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.calc-bar .result small { font-size: 14px; margin-left: 3px; font-weight: 400; }

/* ============== 提示条 ============== */
.toast-wrap { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 300; }

.toast {
  background: var(--text);
  color: #fff;
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  margin-bottom: 8px;
  animation: toastIn .2s ease;
}

.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }

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

/* ============== Excel 导入 ============== */
.drop {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  background: #fafbfc;
}

.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-lighter); }
.drop .t { font-size: 14px; margin-bottom: 6px; }
.drop .s { font-size: 12px; color: var(--text-3); }

.err-list { margin-top: 16px; max-height: 200px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.err-list .r { padding: 8px 12px; font-size: 13px; border-bottom: 1px solid #f1f2f4; color: var(--danger); }
.err-list .r:last-child { border-bottom: none; }

/* ============== 详情 ============== */
.detail-row { display: flex; padding: 11px 0; border-bottom: 1px solid #f1f2f4; }
.detail-row:last-child { border-bottom: none; }
.detail-row .k { width: 120px; color: var(--text-2); font-size: 13px; flex-shrink: 0; }
.detail-row .v { flex: 1; word-break: break-all; }
.detail-row .v.money-v { color: var(--brand-dark); font-weight: 600; font-size: 17px; }

/* ============== 账号管理 ============== */
.role-pick { display: flex; gap: 8px; }
.role-opt {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}

.role-opt.on { border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark); font-weight: 500; }

.st-off { color: var(--text-3); }
.st-on { color: var(--success); }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
::-webkit-scrollbar-track { background: transparent; }

/* 窄屏适配 */
@media (max-width: 900px) {
  .cards { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar input[type=text] { width: 100%; }
}
/* ============ 訂單詳情：商品明細表（置頂表頭 + 排序） ============ */

.di-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  max-height: 420px;
  position: relative;
}

/* ★ 表頭置頂：th 用 sticky，捲動時固定在最上方 */
.di-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--white);
  box-shadow: inset 0 -1px 0 var(--line);
  white-space: nowrap;
}

/* 可點擊排序的表頭 */
.di-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background .12s, color .12s;
}
.di-table th.sortable:hover {
  background: var(--brand-lighter);
  color: var(--brand-dark);
}

/* 排序中的欄位 */
.di-table th.active {
  background: var(--brand-lighter);
  color: var(--brand-dark);
  font-weight: 600;
}

.di-table tbody tr:hover {
  background: var(--brand-lighter);
}

/* ============ 產品檔案：批次操作（勾選欄） ============ */

/* 勾選欄：置中、窄 */
.chk-col {
  width: 42px;
  text-align: center;
  padding-left: 10px !important;
  padding-right: 4px !important;
}

/* 勾選框大一點、好點 */
.chk-col input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  vertical-align: middle;
  accent-color: var(--brand);
}

/* 勾選中的整列淡色高亮 */
#productRows tr:has(input[data-pid]:checked) {
  background: var(--brand-lighter);
}

/* 批次操作列 */
#pdBatchBar {
  animation: pdBatchFade .15s ease-out;
}
@keyframes pdBatchFade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 批次刪除鈕：危險色 */
#pdBatchDelBtn {
  border-color: var(--danger) !important;
  color: var(--danger) !important;
}
#pdBatchDelBtn:hover:not(:disabled) {
  background: var(--danger) !important;
  color: #fff !important;
}
#pdBatchDelBtn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* ============ 儀表板：快捷區間按鈕 ============ */
.dash-chip {
  padding: 9px 16px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background .15s, color .15s;
  white-space: nowrap;
}
.dash-chip:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: var(--brand-lighter);
}
.dash-chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

/* ============ 儀表板：月份選擇框（加大好點） ============ */
.dash-date-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.dash-date-box:hover { border-color: var(--brand); }
.dash-date-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
.dash-date-box input[type="month"] {
  border: none;
  outline: none;
  padding: 0;
  margin: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  width: 112px;
  cursor: pointer;
  font-family: inherit;
}
.dash-date-box svg {
  flex: none;
  color: var(--brand-dark);
  pointer-events: none;
}

/* 儀表板：排行下拉也加大 */
.dash-select {
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
}
.dash-select:hover { border-color: var(--brand); }

/* 隱藏 month 輸入的原生月曆圖示（改用右側大圖示，避免兩個圖示） */
.dash-date-box input[type="month"]::-webkit-calendar-picker-indicator {
  display: none;
  -webkit-appearance: none;
}

/* ============ 訂單管理／產品檔案：表格區塊內捲動 + 表頭凍結 ============ */
/* 欄位較多，允許橫向捲動；直向也改為區塊內捲動，
   讓表頭可以凍結在頂端（往下拉卷軸時表頭不會跟著捲走） */
#page-orders .table-box,
#page-products .table-box {
  overflow: auto;
  min-height: 320px;
}
#page-orders .table-box { max-height: calc(100vh - 430px); }  /* 扣除上方統計卡/篩選列 */
/* 扣除上方工具列/匯率列（勾選後出現的批次列也預留空間） */
#page-products .table-box { max-height: calc(100vh - 360px); }
#page-orders table { min-width: 1180px; }

/* 表頭凍結：捲動時永遠貼在表格區塊頂端 */
#page-orders thead th,
#page-products thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fafbfc;
  box-shadow: inset 0 -1px 0 var(--line);  /* border 會被捲動蓋掉，改用內陰影 */
}

/* 分頁列也固定在表格區塊底部，不用捲到最底才看得到 */
#page-orders .table-box .pager,
#page-products .table-box .pager {
  position: sticky;
  bottom: 0;
  z-index: 4;
  background: var(--white);
}

/* 批次操作列（訂單） */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--brand-lighter);
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  font-size: 13px;
}
.batch-bar .spacer { flex: 1; }
.batch-bar .chk-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--text-1);
  cursor: pointer;
  user-select: none;
}
.batch-bar .chk-all input[type="checkbox"] {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--brand);
}
.batch-bar button:disabled { opacity: .45; cursor: not-allowed; }

/* 勾選中的整列淡色高亮 */
#orderRows tr:has(input.ord-chk:checked) {
  background: var(--brand-lighter);
}

/* 可排序表頭 */
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color .15s;
}
th.sortable:hover { color: var(--brand-dark); }
th.sortable::after {
  content: '⇅';
  margin-left: 4px;
  font-size: 11px;
  opacity: .35;
}
th.sortable.sort-asc::after  { content: '↑'; opacity: 1; color: var(--brand); }
th.sortable.sort-desc::after { content: '↓'; opacity: 1; color: var(--brand); }

/* 管銷費用率儲存格：未設定顯示淡灰的 — */
.ord-rate { font-variant-numeric: tabular-nums; }
.ord-rate.unset { color: var(--text-3); }

/* 確認對話框必須永遠在最上層（否則會被後面加入的彈窗蓋住，
   例如「費用設定」彈窗裡按下儲存後跳出的確認框） */
#confirmMask { z-index: 260; }

/* ===== 表格拖曳平移（抓取圖示） ===== */
/* 滑鼠移到表格上變成「抓取」手勢，按住滑鼠鍵拖曳即可左右／上下平移 */
.table-box.tbl-grab { cursor: grab; }
.table-box.tbl-grabbing {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
}
/* 拖曳時不要讓格子裡的文字被選取成藍底 */
.table-box.tbl-grabbing * { cursor: grabbing !important; user-select: none !important; }
/* 可互動元素維持原本指標 */
.table-box button,
.table-box a,
.table-box input,
.table-box select { cursor: pointer; }

/* ===== 使用日誌：類別標籤 ===== */
.log-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid transparent;
}
.log-tag-auth    { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
.log-tag-order   { background: #e8f5e9; color: #1b5e20; border-color: #c8e6c9; }
.log-tag-product { background: #fff3e0; color: #e65100; border-color: #ffe0b2; }
.log-tag-account { background: #fde8ef; color: #ad1457; border-color: #f8bbd0; }
.log-tag-rate    { background: #e0f7fa; color: #00695c; border-color: #b2ebf2; }
.log-tag-other   { background: #f2f4f7; color: #546e7a; border-color: #dfe3e8; }

/* 表格上方的小提示（含滑鼠圖示） */
.tbl-drag-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  padding: 5px 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-2);
  background: var(--brand-lighter);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.tbl-drag-hint svg { flex: none; color: var(--brand); }
.tbl-drag-hint b { color: var(--text-1); font-weight: 600; }

/* ===== 產品智慧下拉（國際條碼 / 商品名稱） ===== */
#pcPanel {
  position: fixed;
  z-index: 4000;
  display: none;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 16px 44px rgba(15, 23, 42, .18);
  overflow: hidden;
  font-size: 13px;
}
.pc-head > div,
.pc-row {
  display: grid;
  gap: 10px;
  align-items: center;
}
.pc-head {
  padding: 8px 12px;
  background: var(--brand-lighter);
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}
.pc-list { max-height: 280px; overflow: auto; }
.pc-row {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
}
.pc-row:last-child { border-bottom: 0; }
.pc-row:hover { background: var(--brand-lighter); }
.pc-row.on {
  background: var(--brand-light);
  box-shadow: inset 3px 0 0 var(--brand);
}
.pc-bc {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  color: var(--text-2);
  letter-spacing: .3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pc-nm {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pc-cap { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-pr { color: var(--brand-dark); text-align: right; font-variant-numeric: tabular-nums; }
.pc-hl { background: #fff3bf; color: var(--brand-dark); border-radius: 3px; }
.pc-empty { padding: 18px 12px; color: var(--text-3); text-align: center; }
.pc-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: #fafbfc;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: 11px;
}
.pc-foot .pc-tip { margin-left: auto; }
.pc-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M1 3.2l4 4 4-4' fill='none' stroke='%239ca3af' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 20px !important;
  cursor: pointer;
}

/* ===== 分析儀表板：統計卡片（Logo 青漸層 + 立體微陰影） ===== */
#dashCards { gap: 18px; }
#dashCards .card {
  position: relative;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 18px 20px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(0, 176, 184, .10) 0%, rgba(0, 176, 184, 0) 58%),
    linear-gradient(160deg, #ffffff 0%, #f7fdfd 55%, #e9f8f9 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .95),
    0 2px 4px rgba(15, 23, 42, .04),
    0 10px 24px -12px rgba(0, 144, 153, .45);
  transition: transform .18s ease, box-shadow .18s ease;
  overflow: hidden;
}
/* 漸層描邊：左上深青 → 右下淡青 */
#dashCards .card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 14px;
  padding: 1px;
  background: linear-gradient(145deg,
    rgba(0, 176, 184, .90), rgba(0, 176, 184, .10) 45%, rgba(0, 144, 153, .55));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask-composite: exclude;
  pointer-events: none;
}
#dashCards .card:hover {
  transform: translateY(-3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .95),
    0 3px 6px rgba(15, 23, 42, .05),
    0 18px 32px -12px rgba(0, 144, 153, .55);
}
#dashCards .card.hl {
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(0, 176, 184, .16) 0%, rgba(0, 176, 184, 0) 60%),
    linear-gradient(160deg, #ffffff 0%, #eefbfc 55%, #d9f3f5 100%);
}
#dashCards .card .label { color: #0b7c83; font-weight: 600; letter-spacing: .2px; }
#dashCards .card .num {
  font-weight: 700;
  background: linear-gradient(135deg, #00727a 0%, #00a7af 45%, #2fc9d0 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
/* 卡片內的「毛利率 / 淨利率」副標維持灰字，不套漸層 */
#dashCards #d-gpRate,
#dashCards #d-npRate,
#dashCards .card .num small {
  background: none;
  -webkit-text-fill-color: var(--text-2);
  color: var(--text-2);
  font-weight: 400;
}
/* 淨利為負：卡片轉紅 */
#dashCards .card.neg .num {
  background-image: linear-gradient(135deg, #b3261e 0%, #e24b4a 55%, #f08a86 100%);
}

/* 幣別切換下拉（儀表板左上角） */
.toolbar .dash-cur {
  font-weight: 600;
  color: var(--brand-dark);
  border-color: var(--brand-light);
  background: linear-gradient(180deg, #ffffff, #f2fbfb);
}

/* ===== 分析儀表板：幣別旁的「目前匯率」小標籤 ===== */
.dash-fx-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(0, 176, 184, .35);
  background: linear-gradient(180deg, #ffffff, #eefbfc);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 2px 6px -2px rgba(0, 144, 153, .35);
  font-size: 12px;
  color: #0b7c83;
  white-space: nowrap;
  cursor: default;
  user-select: none;
}
.dash-fx-hint b {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 13px;
  font-weight: 700;
  color: #00727a;
  letter-spacing: .2px;
}
.dash-fx-hint .fx-src {
  padding-left: 6px;
  border-left: 1px solid rgba(0, 176, 184, .3);
  color: var(--text-3);
  font-size: 11px;
}
.dash-fx-hint.base {
  border-color: var(--line);
  background: #fafbfc;
  color: var(--text-3);
  box-shadow: none;
}
.dash-fx-hint.base b {
  color: var(--text-2);
}

/* ===== 分析儀表板：頂部分成兩列（第一列篩選工具、第二列統計區間） ===== */
.dash-bar { margin-bottom: 16px; }
.dash-bar-2 a, .dash-bar-2 select { flex: 0 0 auto; }
.dash-bar.dash-bar-2 { margin-top: -6px; }   /* 兩列併在一起，不要隔太開 */
.dash-bar .spacer { flex: 1 1 auto; }
.dash-bar .sep { flex: 0 0 1px; }

/* ===== 訂單明細：手動輸入的成本（橘色標示 + ↺ 還原鈕） ===== */
#v2e-items .v2f-cu.manual {
  border-color: #f0a020 !important;
  background: #fffaf0;
  color: #b45309;
  font-weight: 600;
}
#v2e-items .v2f-cu.manual:focus {
  box-shadow: 0 0 0 3px rgba(240, 160, 32, .18);
}
#v2e-items .v2f-cu-reset {
  margin-left: 3px;
  width: 20px;
  height: 26px;
  line-height: 1;
  padding: 0;
  border: 1px solid #f0a020;
  border-radius: 6px;
  background: #fff;
  color: #b45309;
  font-size: 12px;
  cursor: pointer;
  vertical-align: middle;
}
#v2e-items .v2f-cu-reset:hover { background: #fff3e0; }

/* ===== 自訂月份選擇器（取代瀏覽器原生面板） ===== */
.dash-date-box input[type="month"]::-webkit-calendar-picker-indicator { display: none; }
.dash-date-box input[type="month"][readonly] { cursor: pointer; }

.mp-panel {
  position: fixed;
  z-index: 4200;
  width: 272px;
  display: none;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .06);
  padding-top: 8px;
  user-select: none;
  font-size: 13px;
}
.mp-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 6px;
}
.mp-title {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .5px;
  color: var(--brand-dark);
}
.mp-nav {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--brand-dark);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.mp-nav:hover { border-color: var(--brand); background: var(--brand-lighter); }

/* 年份清單：hover = Logo 青色反白（青底白字） */
.mp-years {
  max-height: 106px;
  overflow: auto;
  padding: 2px 8px 6px;
  border-bottom: 1px solid #f3f4f6;
}
.mp-year {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  margin-bottom: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background .12s, color .12s, box-shadow .12s;
}
.mp-year:hover,
.mp-year:focus-visible {
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%);
  color: #fff;
  font-weight: 700;
  outline: none;
  box-shadow: 0 4px 10px -4px rgba(0, 144, 153, .7);
}
.mp-year.sel {
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--brand);
}
.mp-year.sel:hover,
.mp-year.sel:focus-visible {
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%);
  color: #fff;
  box-shadow: 0 4px 10px -4px rgba(0, 144, 153, .7);
}

/* 月份 4×3 */
.mp-months {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px;
}
.mp-month {
  padding: 8px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, color .12s, box-shadow .12s;
}
.mp-month:hover {
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 600;
}
.mp-month.now { box-shadow: inset 0 0 0 1.5px var(--brand); }
.mp-month.on {
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 3px 8px -3px rgba(0, 144, 153, .7);
}
.mp-month.on.now { box-shadow: 0 3px 8px -3px rgba(0, 144, 153, .7); }

.mp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid #f3f4f6;
}
.mp-foot-btn {
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--brand-dark);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.mp-foot-btn:hover { background: var(--brand-lighter); }
.mp-foot-btn.primary { font-weight: 600; }

/* ===== 授權頁（未啟用時覆蓋全畫面） ===== */
body.lic-locked { overflow: hidden; }

.lic-gate {
  position: fixed;
  inset: 0;
  z-index: 99998;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(0, 176, 184, .10) 0%, rgba(0, 176, 184, 0) 55%),
    linear-gradient(180deg, #ffffff 0%, #f4fbfb 100%);
}
.lic-card {
  width: min(560px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 30px 32px 26px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .12), 0 2px 6px rgba(15, 23, 42, .05);
}
.lic-brand {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-3);
}
.lic-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand-dark);
  margin: 6px 0 10px;
}
.lic-msg {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.75;
  margin-bottom: 18px;
  min-height: 22px;
}
.lic-msg-error { color: var(--danger); font-weight: 500; }

.lic-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--brand-lighter);
  border: 1px solid #b5e5e7;
  border-radius: 10px;
}
.lic-label { font-size: 12px; color: var(--text-2); flex: none; }
.lic-row code {
  flex: 1;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--brand-dark);
  word-break: break-all;
}

.lic-actions { margin-top: 18px; }
.lic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  cursor: pointer;
}
.lic-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.8;
}
.lic-hint code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}
.lic-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.8;
}

/* ===== 到期／即將到期橫幅 ===== */
body.lic-has-banner { padding-top: 42px; }
.lic-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99997;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  font-size: 13.5px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .08);
}
.lic-banner-danger { background: #fdecec; color: #8a1f1f; border-bottom: 1px solid #f3c6c6; }
.lic-banner-warn { background: #fff7e6; color: #8a5a00; border-bottom: 1px solid #f6dfae; }
.lic-banner-ico { font-size: 15px; flex: none; }
.lic-banner-btn {
  margin-left: auto;
  flex: none;
  padding: 4px 10px;
  border: 1px solid currentColor;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.lic-banner-btn:hover { background: rgba(0, 0, 0, .05); }
.lic-banner-close {
  flex: none;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: .55;
}
.lic-banner-close:hover { opacity: 1; }

/* ===== 小提示 ===== */
.lic-toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  z-index: 100000;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(31, 41, 55, .94);
  color: #fff;
  font-size: 13.5px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .2);
  transition: opacity .25s, transform .25s;
}
.lic-toast.out { opacity: 0; transform: translateX(-50%) translateY(8px); }

/* ===== 帳號管理頁的「系統授權」資訊卡 ===== */
.lic-info-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.lic-info-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.lic-info-sub { font-size: 12.5px; color: var(--text-2); }

.lic-pill {
  flex: none;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}
.lic-pill-ok       { background: #e8f6ee; color: #1a6b40; }
.lic-pill-warn     { background: #fef3e2; color: #b45309; }
.lic-pill-danger   { background: #fdecec; color: #8a1f1f; }
.lic-pill-loading  { background: var(--bg-2, #f1f3f5); color: var(--text-2); }

.lic-info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 18px;
  margin-bottom: 14px;
}
.lic-info-grid > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.lic-info-grid span {
  font-size: 12px;
  color: var(--text-2);
}
.lic-info-grid b {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}
.lic-info-grid b.lic-strong { color: var(--brand-dark); }

.lic-info-mid {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-2, #f7f8f9);
}
.lic-info-midlabel { font-size: 12px; color: var(--text-2); flex: none; }
.lic-info-mid code {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 6px;
  padding: 3px 10px;
}

.lic-info-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-3, var(--text-2));
  word-break: break-all;
}

.lic-info-policy {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.lic-info-policy select {
  max-width: 440px;
  font-size: 12.5px;
}

@media (max-width: 1100px) {
  .lic-info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ===== 我的客戶（購買本系統）名單 ===== */
.cli-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: #fff7e6;
  color: #8a5a00;
  border: 1px solid #f6dfae;
  font-size: 13px;
  line-height: 1.6;
}
.cli-alert-ico { font-size: 14px; flex: none; }

.cli-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.cli-pill-ok      { background: #e8f6ee; color: #1a6b40; }
.cli-pill-warn    { background: #fef3e2; color: #b45309; }
.cli-pill-danger  { background: #fdecec; color: #8a1f1f; }
.cli-pill-info    { background: #e8f1fd; color: #1d4ed8; }
.cli-pill-loading { background: #f1f3f5; color: #6b7280; }
