/* ============================================================
   SCHEDULE 開發進度平台 — 共用樣式
   設計 tokens:淺/深色兩套,依系統設定自動切換
   ============================================================ */

:root {
  color-scheme: light;
  /* 平面與表面 */
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --border: rgba(11, 11, 11, 0.10);
  --grid: #e1e0d9;
  /* 文字 */
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  /* 主色(資料/強調) */
  --accent: #2a78d6;
  --accent-strong: #1c5cab;
  --accent-track: #cde2fb;
  --accent-wash: rgba(42, 120, 214, 0.08);
  /* 狀態色 */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --success-text: #006300;
  --row-alt: #f6f6f3;
  --row-hover: #ebf1f8;
  /* 進度表格:白底黑線 */
  --table-line: #3d3d3d;
  --table-bg: #ffffff;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --border: rgba(255, 255, 255, 0.10);
    --grid: #2c2c2a;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --accent: #3987e5;
    --accent-strong: #6da7ec;
    --accent-track: #104281;
    --accent-wash: rgba(57, 135, 229, 0.14);
    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-serious: #ec835a;
    --status-critical: #d03b3b;
    --success-text: #0ca30c;
    --row-alt: #201f1e;
    --row-hover: #1e2936;
    --table-line: #9a9a9a;
    --table-bg: #1a1a19;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 頂部導覽列 ---------- */

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

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  white-space: nowrap;
}
.topbar .brand:hover { text-decoration: none; }

.topbar .brand .logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.topbar .brand .brand-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 8px;
}

.topbar nav {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
}

.topbar nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  white-space: nowrap;
}
.topbar nav a:hover { background: var(--accent-wash); text-decoration: none; }
.topbar nav a.active {
  background: var(--accent-wash);
  color: var(--accent);
  font-weight: 600;
}

.topbar .user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: var(--accent-wash); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn-ghost { border-color: transparent; background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--accent-wash); color: var(--accent); }

/* ---------- 版面 ---------- */

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.page-head { margin: 8px 0 24px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; font-weight: 700; }
.page-head .sub { margin: 0; color: var(--text-secondary); font-size: 14px; }

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

.card h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.card h2 .hint { font-weight: 400; font-size: 13px; color: var(--text-muted); margin-left: 8px; }

.section { margin-bottom: 24px; }

/* ---------- 入口頁功能卡 ---------- */

.portal-hero { margin: 16px 0 28px; }
.portal-hero h1 { margin: 0 0 6px; font-size: 28px; }
.portal-hero p { margin: 0; color: var(--text-secondary); }

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.portal-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  color: var(--text-primary);
  transition: transform 0.15s, border-color 0.15s;
}
.portal-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--accent);
}

.portal-card .icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent-wash);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.portal-card .title { font-size: 16px; font-weight: 700; }
.portal-card .desc { font-size: 13px; color: var(--text-secondary); }
.portal-card .go { margin-top: auto; font-size: 13px; color: var(--accent); font-weight: 600; }

.portal-card.disabled {
  opacity: 0.55;
  pointer-events: none;
}
.portal-card.disabled .go { color: var(--text-muted); }

/* ---------- 統計方塊(stat tiles) ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.stat-tile .label { font-size: 13px; color: var(--text-secondary); }
.stat-tile .value { font-size: 30px; font-weight: 650; line-height: 1.2; margin-top: 2px; }
.stat-tile .delta { font-size: 12.5px; margin-top: 4px; color: var(--text-muted); }
.stat-tile .delta.up { color: var(--success-text); }
.stat-tile .delta.warn { color: var(--status-critical); }

/* ---------- 長條圖(階段分佈) ---------- */

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

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 12px;
}

.bar-row .bar-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: right;
}

.bar-row .bar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }

.bar-row .bar-fill {
  height: 20px;
  max-height: 24px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;   /* 資料端圓角,基線端直角 */
  transition: width 0.4s ease;
}
.bar-row:hover .bar-fill { background: var(--accent-strong); }

.bar-row .bar-value { font-size: 13px; color: var(--text-primary); font-weight: 600; }

/* ---------- 進度條(meter) ---------- */

.meter {
  height: 8px;
  border-radius: 4px;
  background: var(--accent-track);
  overflow: hidden;
  min-width: 90px;
}
.meter > span {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}

/* ---------- 階段流程(pipeline) ---------- */

.pipeline {
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  padding: 6px 0 2px;
}

.pipeline .step {
  flex: 1;
  min-width: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  text-align: center;
}

.pipeline .step::before,
.pipeline .step::after {
  content: "";
  position: absolute;
  top: 16px;
  height: 2px;
  width: 50%;
  background: var(--grid);
}
.pipeline .step::before { left: 0; }
.pipeline .step::after { right: 0; }
.pipeline .step:first-child::before,
.pipeline .step:last-child::after { display: none; }

.pipeline .step.done::before,
.pipeline .step.done::after,
.pipeline .step.current::before { background: var(--accent); }

.pipeline .dot {
  position: relative;
  z-index: 1;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 17px;
  background: var(--surface);
  border: 2px solid var(--grid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}
.pipeline .step.done .dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.pipeline .step.current .dot {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-wash);
}

.pipeline .step .name { font-size: 12.5px; color: var(--text-secondary); }
.pipeline .step.current .name { color: var(--accent); font-weight: 700; }
.pipeline .step .count { font-size: 11.5px; color: var(--text-muted); }

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}

table.data td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--grid);
  vertical-align: middle;
  white-space: nowrap;
}

table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { background: var(--surface); }
table.data tbody tr:nth-child(even) { background: var(--row-alt); }
table.data tbody tr:hover { background: var(--row-hover); }

table.data td.num { font-variant-numeric: tabular-nums; }

/* ---------- 權限相關 ---------- */

.role-badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-wash);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.scope-note { color: var(--accent) !important; font-weight: 600; }

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

.view-only { font-size: 12.5px; color: var(--text-muted); }

/* ---------- 狀態標籤 ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--surface);
}
.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.badge.good { color: var(--success-text); }
.badge.good::before { background: var(--status-good); }
.badge.warn { color: var(--text-primary); }
.badge.warn::before { background: var(--status-warning); }
.badge.late { color: var(--status-critical); }
.badge.late::before { background: var(--status-critical); }

/* ---------- 佔位(建置中) ---------- */

.placeholder {
  border: 1.5px dashed var(--grid);
  border-radius: 14px;
  padding: 40px 24px;
  text-align: center;
  color: var(--text-muted);
  background: transparent;
}
.placeholder .ph-icon { font-size: 30px; margin-bottom: 8px; }
.placeholder .ph-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.placeholder .ph-desc { font-size: 13px; margin-top: 4px; }

/* ---------- 登入頁 ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.login-card .logo-lg {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
}

.login-card .eyebrow {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--accent);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { margin: 0 0 22px; color: var(--text-secondary); font-size: 13.5px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  font-size: 14.5px;
  font-family: inherit;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.login-error {
  display: none;
  margin: 0 0 14px;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(208, 59, 59, 0.10);
  color: var(--status-critical);
  font-size: 13px;
}
.login-error.show { display: block; }

.login-hint {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--grid);
  font-size: 12.5px;
  color: var(--text-muted);
}
.login-hint code {
  background: var(--accent-wash);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12px;
}

/* ---------- 後台管理:頁籤 ---------- */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--grid);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 16px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--accent); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
}

/* ---------- 後台管理:表單與勾選 ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 4px 18px;
}

.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  font-size: 14.5px;
  font-family: inherit;
}

.radio-row { display: flex; flex-wrap: wrap; gap: 14px; padding: 8px 0; }

label.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 400;
}
label.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.muted-note { margin: 2px 0 10px; font-size: 13px; color: var(--text-muted); }

.scope-boxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.center-group {
  border: 1px solid var(--grid);
  border-radius: 10px;
  padding: 12px 14px;
}
.center-group .center-check { display: flex; }
.center-group .brands {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--grid);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.center-group .brands label.check input:disabled + * { color: var(--text-muted); }

.form-actions { display: flex; gap: 10px; margin-top: 14px; }

.form-error {
  display: none;
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(208, 59, 59, 0.10);
  color: var(--status-critical);
  font-size: 13px;
}
.form-error.show { display: block; }

.btn-danger { color: var(--status-critical); }
.btn-danger:hover { background: rgba(208, 59, 59, 0.10); }

/* 品牌管理 */
.brand-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.brand-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand-row .brand-center { font-weight: 700; font-size: 14px; min-width: 52px; }
.brand-row .brand-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.brand-add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.brand-add-row select, .brand-add-row input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
}
.brand-add-row input { flex: 1; min-width: 160px; }

/* ---------- 總覽 ---------- */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}

tr.row-link { cursor: pointer; }

/* ---------- 功能2/3:搜尋、儲存格編輯、提示 ---------- */

.search-input {
  flex: 1;
  min-width: 220px;
  max-width: 440px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.dropdown { position: relative; }
.dropdown-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 10px 14px;
  z-index: 60;
  display: none;
  min-width: 170px;
}
.dropdown-panel.open { display: block; }
.dropdown-panel label.check { display: flex; padding: 4px 0; white-space: nowrap; }

/* 儲存格直接編輯 */
td.cell-edit { cursor: cell; }
td.cell-edit:hover { box-shadow: inset 0 0 0 1.5px var(--accent); }
td.editing { padding: 0 !important; }
.cell-input {
  width: 100%;
  min-width: 96px;
  border: none;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12.5px;
  padding: 6px 8px;
  box-sizing: border-box;
}
td.cell-readonly { cursor: not-allowed; }

/* 鞋圖 */
.shoe-cell { text-align: center; padding: 3px 4px !important; }
.shoe-thumb {
  max-height: 44px;
  max-width: 100%;
  border-radius: 4px;
  cursor: zoom-in;
  display: inline-block;
  vertical-align: middle;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 300;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 82vw;
  max-height: 70vh;
  background: #fff;
  border-radius: 10px;
  padding: 6px;
}
.lightbox .lb-actions { display: flex; gap: 10px; }
.lightbox .btn { background: #fff; color: #111; border-color: transparent; }
.lightbox .btn-primary { background: var(--accent); color: #fff; }
.lightbox .btn-danger { color: #d03b3b; }

/* 鞋型試做狀況:V/X 顯示與三層表頭 */
.vx-v { color: var(--success-text); font-weight: 700; }
.vx-x { color: var(--status-critical); font-weight: 700; }
/* 三層表頭高度不一,表頭僅左向凍結、不做上方凍結 */
table.data.compact thead.three-row th { top: auto; }

/* 輕量提示(toast) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: var(--text-primary);
  color: var(--page);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 功能2/3:進度表與示警 ---------- */

/* 表格型頁面:滿版使用整個螢幕寬度 */
.container-wide { max-width: none; padding-left: 20px; padding-right: 20px; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.toolbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar-actions select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
}

/* 固定欄寬版面:每欄寬度由 colgroup 指定;白底黑線網格
   注意:凍結欄需搭配 border-collapse: separate,
   框線才會跟著儲存格一起固定(collapse 模式下捲動時框線會消失) */
table.data.compact {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  border-top: 1px solid var(--table-line);
  border-left: 1px solid var(--table-line);
}
table.data.compact th, table.data.compact td {
  font-size: 12.5px;
  padding: 6px 8px;
  border-right: 1px solid var(--table-line);
  border-bottom: 1px solid var(--table-line);
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  vertical-align: middle;
  background: var(--table-bg);
}
table.data.compact tbody tr,
table.data.compact tbody tr:nth-child(even) { background: var(--table-bg); }
table.data.compact tbody tr:hover td { background: var(--row-hover); }
table.data.compact tbody tr:last-child td { border-bottom: 1px solid var(--table-line); }
/* 表頭:置中,依指定斷點換行 */
table.data.compact thead th {
  text-align: center;
  text-wrap: balance;
  line-height: 1.35;
}
/* 日期與數字:置中對齊 */
table.data.compact td.num {
  text-align: center;
  font-variant-numeric: tabular-nums;
}
table.data.compact td { line-height: 1.4; }
table.data.compact thead th {
  position: sticky;
  top: 0;
  background: var(--table-bg);
  z-index: 4;
}
/* 兩層表頭:第一列為欄位群組 */
table.data.compact thead.two-row tr:first-child th {
  font-size: 12px;
  line-height: 16px;
  padding: 4px 8px;
  height: 16px;
}
table.data.compact thead.two-row tr:nth-child(2) th { top: 25px; }
.group-th {
  text-align: center;
  color: var(--text-primary);
  background: var(--table-bg) !important;
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 凍結欄(左側固定,捲動時保持可見) */
.c-sticky { position: sticky; z-index: 3; }
table.data.compact thead th.c-sticky { z-index: 6; }
.f2-act .btn { display: block; width: 100%; margin: 2px 0; text-align: center; }
.f2-last-sticky { box-shadow: 1px 0 0 var(--table-line); }
.cell-model { font-weight: 600; }
.t-no { left: 0; }
.t-cust { left: 40px; }
.t-model { left: 150px; font-weight: 600; box-shadow: 1px 0 0 var(--table-line); }

/* 量產試做排程:淺色格線、鞋款區塊隔行底色,對齊新版型 */
table.data.compact.tech-table,
table.data.compact.tech-table th,
table.data.compact.tech-table td {
  border-color: var(--grid);
}
table.data.compact.tech-table thead th {
  color: var(--text-secondary);
  font-weight: 600;
}
.tech-table .model-first-row td { border-top: 1.5px solid var(--grid); }
.tech-table tr.model-alt td { background: var(--pa-tint); }
.tech-table tbody tr:hover td { background: var(--row-hover); }
.tech-table .t4-cell { font-size: 11.5px; padding: 2px 6px !important; }
.region-tag {
  display: inline-block;
  min-width: 24px;
  text-align: center;
  padding: 0 4px;
  border-radius: 5px;
  background: var(--accent-wash);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.pending-box {
  border: 1.5px solid var(--status-warning);
  background: rgba(250, 178, 25, 0.08);
  border-radius: 12px;
  padding: 14px 16px;
}
.pending-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.pending-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-top: 1px solid var(--grid);
  font-size: 13.5px;
}
.pending-item s { color: var(--text-muted); }
.pending-actions { white-space: nowrap; }
.pending-mark { cursor: help; }

.shared-tag, .own-tag {
  display: inline-block;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
}
.shared-tag { background: var(--accent-wash); color: var(--accent); }
.own-tag { background: rgba(12, 163, 12, 0.12); color: var(--success-text); }

.editor-group { margin-bottom: 14px; }
.editor-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--grid);
  padding-bottom: 4px;
  margin-bottom: 10px;
}

.import-ok {
  display: none;
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(12, 163, 12, 0.10);
  color: var(--success-text);
  font-size: 13px;
}
.import-ok.show { display: block; }

/* ---------- 篩選列(佔位) ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.chip {
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.chip:hover { background: var(--accent-wash); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---------- 功能2:鞋型資訊整合欄(基本資料/訂單/人員) ---------- */

td.info-cell { padding: 7px 10px !important; text-align: left; }

.shoe-info {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.si-img {
  flex: 0 0 84px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--row-alt);
  border: 1px solid var(--grid);
  border-radius: 8px;
  overflow: hidden;
}
.si-img .shoe-thumb {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain; /* 等比例縮放,不變形 */
  background: #fff;
}
.si-noimg { color: var(--text-muted); font-size: 19px; }
.si-upload {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 11.5px;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.si-upload:hover { text-decoration: underline; }

.si-main { flex: 1; min-width: 0; }

.si-line1 {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.si-name {
  font-weight: 700;
  font-size: 13px;
  line-height: 1.3;
  margin: 1px 0 4px;
}
.si-code { font-weight: 400; font-size: 11px; color: var(--text-muted); }

.si-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding-right: 58px; /* 讓出右下角「編輯」按鈕的位置 */
}

.si-chip {
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.7;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  white-space: nowrap;
  font-family: inherit;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
button.si-chip { cursor: pointer; }

.chip-muted { color: var(--text-muted); }
.chip-factory { font-weight: 600; }

.chip-basic {
  border-color: rgba(224, 127, 20, 0.55);
  background: rgba(250, 178, 25, 0.10);
  color: #a06a00;
  font-weight: 700;
}
.chip-basic:hover { background: rgba(250, 178, 25, 0.24); }

.chip-br {
  border-color: transparent;
  background: var(--accent-wash);
  color: var(--accent);
  font-weight: 600;
}

.chip-p0 { border-color: transparent; background: rgba(124, 77, 255, 0.12); color: #6f42d8; }
.chip-p1 { border-color: transparent; background: rgba(236, 131, 90, 0.16); color: #bf5028; }
.chip-p2 { border-color: transparent; background: rgba(250, 178, 25, 0.16); color: #96690a; }
.chip-p3 { border-color: transparent; background: rgba(12, 163, 12, 0.13); color: var(--success-text); }

@media (prefers-color-scheme: dark) {
  .chip-basic { color: #f2b755; }
  .chip-p0 { color: #b39cf5; }
  .chip-p1 { color: #f09f7c; }
  .chip-p2 { color: #f2c467; }
}

.si-edit {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 2px 10px;
  font-size: 12px;
}

/* ---------- 彈窗(編輯鞋款 / # 基本資料) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 16px;
  z-index: 250;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 880px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.modal-sm { max-width: 620px; }

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--grid);
}
.modal-title {
  flex: 1;
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-x {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 9px;
  border-radius: 7px;
}
.modal-x:hover { background: var(--accent-wash); color: var(--text-primary); }

.modal-tabs { padding: 0 20px; margin-bottom: 0; flex: 0 0 auto; }
.modal-tabs .tab::before {
  content: "●";
  font-size: 8px;
  margin-right: 6px;
  vertical-align: 2px;
  color: var(--grid);
}
.modal-tabs .tab.active::before { color: var(--accent); }

.modal-body { padding: 16px 20px; overflow-y: auto; }

.modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--grid);
}
.foot-spacer { flex: 1; }

.edit-tab-panel { display: none; }
.edit-tab-panel.active { display: block; }

.req { color: var(--status-critical); }

/* ---------- 功能2:仿參考版型(統計卡 / 計畫實際 / 淺色表格) ---------- */

:root { --pa-tint: #f5f5fc; }
@media (prefers-color-scheme: dark) {
  :root { --pa-tint: #1d1d26; }
}

.toolbar-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

/* 近一週 / 全部 切換 */
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  flex: 0 0 auto;
}
.seg-btn {
  padding: 7px 14px;
  background: var(--surface);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-secondary);
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn:hover { background: var(--accent-wash); }
.seg-btn.active { background: var(--accent-wash); color: var(--accent); font-weight: 700; }

/* 匯出 / 匯入 下拉面板 */
.io-panel { min-width: 210px; display: none; }
.io-panel.open { display: block; }
.io-panel .btn { width: 100%; justify-content: flex-start; margin: 3px 0; }
#import-wrap { flex-direction: column; gap: 6px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--grid); }
#import-wrap select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
}

/* 統計卡(嚴重延誤 / 即將到期 / 待完成) */
.pa-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.pa-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: box-shadow 0.15s, transform 0.15s;
}
.pa-stat:hover { transform: translateY(-1px); }
.pa-stat.active { box-shadow: 0 0 0 3px var(--accent-wash); border-color: var(--accent); }
.pa-stat .ps-label { font-weight: 700; }
.pa-stat .ps-value { margin-left: auto; font-size: 26px; font-weight: 800; }
.pa-late { background: rgba(208, 59, 59, 0.08); border-color: rgba(208, 59, 59, 0.35); }
.pa-late .ps-label, .pa-late .ps-value, .pa-late .ps-ico { color: var(--status-critical); }
.pa-due { background: rgba(250, 178, 25, 0.10); border-color: rgba(250, 178, 25, 0.5); }
.pa-due .ps-ico { color: #b07713; }
.pa-todo .ps-ico { color: var(--text-muted); }

/* 淺色格線表格(仿參考版型) */
table.data.compact.pa,
table.data.compact.pa th,
table.data.compact.pa td {
  border-color: var(--grid);
}
table.data.compact.pa thead th {
  color: var(--text-secondary);
  font-weight: 600;
}
table.data.compact.pa tbody tr:nth-child(even) td { background: var(--pa-tint); }
table.data.compact.pa tbody tr:hover td { background: var(--row-hover); }

/* 計畫 / 實際 兩行式儲存格 */
td.pa-cell { padding: 5px 8px !important; position: relative; }
td.pa-cell::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
}
td.pa-cell.pa-bar-plan::before { background: var(--status-good); }
td.pa-cell.pa-bar-due::before { background: var(--status-warning); }
td.pa-cell.pa-bar-late::before { background: var(--status-critical); }

.pa-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  line-height: 1.7;
  padding: 0 2px;
  border-radius: 4px;
}
.pa-row.pa-plan { border-bottom: 1px dashed var(--grid); }
.pa-tag { font-size: 10.5px; color: var(--text-muted); flex: 0 0 auto; }
.pa-val { font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pa-val.pa-empty { color: var(--text-muted); font-weight: 400; }
.pa-val.pa-act-txt { color: var(--accent); font-weight: 700; }
.pa-val.pa-late-txt { color: var(--status-critical); font-weight: 700; }
.pa-row.pa-can-edit { cursor: cell; }
.pa-row.pa-can-edit:hover { box-shadow: inset 0 0 0 1.5px var(--accent); }
.pa-edit-tag { font-size: 10.5px; color: var(--accent); font-weight: 700; padding: 0 2px; }

/* # 基本資料 快速檢視 */

.qv-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 13px 13px 0 0;
  background: linear-gradient(135deg, #f2a33c, #e07f14);
  color: #fff;
}
.qv-title { flex: 1; font-weight: 800; font-size: 16px; }
.qv-x { color: rgba(255, 255, 255, 0.85); }
.qv-x:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }

.qv-card {
  border: 1px solid rgba(224, 127, 20, 0.45);
  background: rgba(250, 178, 25, 0.10);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.qv-model { font-weight: 800; font-size: 15px; }
.qv-sub { font-size: 12.5px; color: var(--text-secondary); }

.qv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.qv-field {
  border: 1px solid var(--grid);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--row-alt);
}
.qv-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.qv-value { font-size: 13px; margin-top: 2px; word-break: break-word; }
.qv-value.qv-empty { color: var(--text-muted); }

/* ---------- 頁尾 ---------- */

.footer {
  margin-top: 40px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ---------- 響應式 ---------- */

@media (max-width: 640px) {
  .topbar { padding: 0 14px; gap: 12px; }
  .topbar .user-box .user-name,
  .topbar .user-box .role-badge { display: none; }
  .container { padding: 20px 14px 48px; }
  .bar-row { grid-template-columns: 84px 1fr; }
}
