*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', '微軟正黑體', sans-serif;
  background: #e8edf2;
  height: 100vh;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

/* ── Login page ──────────────────────────────────────────────── */
body.login-body {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5a8e 100%);
}
#login-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#login-box {
  background: #fff;
  border-radius: 20px;
  padding: 40px 36px 36px;
  width: 340px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
#login-logo    { font-size: 48px; }
#login-title   { font-size: 22px; font-weight: 800; color: #1e3a5f; }
#login-subtitle{ font-size: 13px; color: #94a3b8; margin-bottom: 8px; }
#login-error {
  width: 100%;
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 9px 13px;
  font-size: 13px;
  text-align: center;
  margin-bottom: 4px;
}
#login-form { width: 100%; display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.login-field { display: flex; flex-direction: column; gap: 5px; }
.login-field label { font-size: 13px; font-weight: 600; color: #475569; }
.login-field input {
  padding: 10px 13px;
  border: 1.5px solid #cbd5e1;
  border-radius: 9px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.login-field input:focus { border-color: #3b82f6; }
#login-btn {
  margin-top: 4px;
  padding: 11px;
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5a8e 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 2px;
  transition: opacity .15s;
}
#login-btn:hover { opacity: .88; }

/* ── Sidebar ─────────────────────────────────────────────────── */
#sidebar {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #1e3a5f 0%, #162d4a 100%);
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  transition: width .25s ease;
  z-index: 20;
}
#sidebar.sidebar-expanded { width: 180px; }
#sidebar.sidebar-collapsed { width: 52px; }

#sidebar-header {
  display: flex;
  align-items: center;
  padding: 12px 8px;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
  min-height: 52px;
}
#sidebar-logo {
  font-size: 20px;
  flex-shrink: 0;
  transition: opacity .2s;
}
#sidebar.sidebar-collapsed #sidebar-logo { opacity: 0; width: 0; overflow: hidden; }
#sidebar-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  flex: 1;
  overflow: hidden;
  opacity: 1;
  transition: opacity .2s;
}
#sidebar.sidebar-collapsed #sidebar-title { opacity: 0; width: 0; }
#sidebar-toggle {
  background: rgba(255,255,255,.18);
  border: none;
  color: #fff;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  margin-left: auto;
}
#sidebar-toggle:hover { background: rgba(255,255,255,.32); }
/* 收合時讓 toggle 置中於整個 header */
#sidebar.sidebar-collapsed #sidebar-header {
  justify-content: center;
  padding: 12px 0;
}
#sidebar.sidebar-collapsed #sidebar-toggle { margin-left: 0; }

#sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 0 6px 4px;
  background: rgba(255,255,255,.1);
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}
#sidebar-user-icon { font-size: 16px; flex-shrink: 0; }
#sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transition: opacity .2s;
}
#sidebar.sidebar-collapsed #sidebar-user { justify-content: center; padding: 8px 0; margin: 0 4px 4px; }
#sidebar.sidebar-collapsed #sidebar-user-name { opacity: 0; width: 0; }

#sidebar-menu {
  list-style: none;
  padding: 10px 6px;
  flex: 1;
  overflow-y: auto;
}
.menu-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 10px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
}
.menu-item a:hover { background: rgba(255,255,255,.12); color: #fff; }
.menu-item.active a { background: rgba(255,255,255,.2); color: #fff; font-weight: 700; }
.menu-icon { font-size: 18px; flex-shrink: 0; }
.menu-label {
  font-size: 13px;
  opacity: 1;
  transition: opacity .2s;
  overflow: hidden;
}
#sidebar.sidebar-collapsed .menu-label { opacity: 0; width: 0; }
/* 收合時圖示置中 */
#sidebar.sidebar-collapsed .menu-item a {
  justify-content: center;
  padding: 9px 0;
}
#sidebar.sidebar-collapsed #sidebar-menu { padding: 10px 4px; }

#sidebar-footer {
  padding: 6px 6px 12px;
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,.1);
}
#sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 10px;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
}
#sidebar-logout:hover { background: rgba(239,68,68,.25); color: #fca5a5; }
#sidebar.sidebar-collapsed #sidebar-logout { justify-content: center; }
#sidebar.sidebar-collapsed #sidebar-logout .menu-label { opacity: 0; width: 0; }

/* ── Main content area ───────────────────────────────────────── */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Toolbar ─────────────────────────────────────────────────── */
#toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5a8e 100%);
  color: #fff;
  flex-shrink: 0;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  z-index: 10;
}

#toolbar-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .5px;
}

#toolbar-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  padding: 7px 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: opacity .15s, transform .1s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn:hover  { opacity: .88; }
.btn:active { transform: scale(.97); }

.btn-primary { background: #3b82f6; color: #fff; }
.btn-success { background: #22c55e; color: #fff; }
.btn-info    { background: #06b6d4; color: #fff; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-danger  { background: #ef4444; color: #fff; }
.btn-ghost   { background: rgba(255,255,255,.15); color: #fff; }

/* small column buttons */
.col-btn {
  flex: 1;
  padding: 5px 4px;
  font-size: 11px;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity .15s;
}
.col-btn:hover { opacity: .82; }
.col-btn-add   { background: #3b82f6; color: #fff; }
.col-btn-batch { background: #8b5cf6; color: #fff; }
.col-btn-clear { background: #94a3b8; color: #fff; }
.col-btn-piao  { background: #ef4444; color: #fff; }

/* ── Board ───────────────────────────────────────────────────── */
#board {
  display: flex;
  flex-direction: row;
  gap: 14px;
  padding: 16px 18px 18px;
  overflow: hidden;
  flex: 1;
  align-items: stretch;
}

/* 待排工卡：左側固定欄，可無限向下延伸 */
#pending-wrapper {
  flex-shrink: 0;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(30,58,95,.25) transparent;
}
#pending-wrapper::-webkit-scrollbar { width: 5px; }
#pending-wrapper::-webkit-scrollbar-thumb { background: rgba(30,58,95,.25); border-radius: 4px; }

#pending-wrapper .dyeing-col {
  max-height: none;
  height: auto;
}

/* 染機格狀區：每排 8 台，自動換行，可垂直捲動 */
#machines-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-content: flex-start;
  overflow-y: auto;
  flex: 1;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(30,58,95,.25) transparent;
}
#machines-grid::-webkit-scrollbar { width: 6px; }
#machines-grid::-webkit-scrollbar-thumb { background: rgba(30,58,95,.25); border-radius: 4px; }

/* ── Column (capsule) ────────────────────────────────────────── */
.dyeing-col {
  display: flex;
  flex-direction: column;
  width: 185px;
  min-width: 185px;
  max-height: calc(100vh - 110px);
  background: #d1dce9;
  border-radius: 30px;
  padding: 12px 10px 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}

.dyeing-col.pending-col {
  background: #bfdbfe;
}

.col-header {
  text-align: center;
  font-weight: 800;
  font-size: 15px;
  color: #1e3a5f;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(30,58,95,.2);
  flex-shrink: 0;
  letter-spacing: .5px;
}

.pending-col .col-header {
  color: #1d4ed8;
}

.col-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 2px 4px;
  min-height: 40px;
  scrollbar-width: thin;
  scrollbar-color: rgba(30,58,95,.25) transparent;
}
.col-body::-webkit-scrollbar { width: 5px; }
.col-body::-webkit-scrollbar-thumb { background: rgba(30,58,95,.25); border-radius: 4px; }

.col-footer {
  display: flex;
  gap: 5px;
  padding-top: 8px;
  border-top: 2px solid rgba(30,58,95,.2);
  flex-shrink: 0;
}

/* ── Work Card ───────────────────────────────────────────────── */
.dye-card {
  background: #fff;
  border-radius: 12px;
  padding: 9px 10px;
  margin-bottom: 7px;
  box-shadow: 0 1px 4px rgba(0,0,0,.10);
  cursor: grab;
  border-left: 5px solid #94a3b8;
  position: relative;
  user-select: none;
  transition: box-shadow .15s;
}
.dye-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,.18); }
.dye-card:active { cursor: grabbing; }

.dye-card.state-in_production { border-left-color: #22c55e; }
.dye-card.state-pending        { border-left-color: #94a3b8; }
.dye-card.state-done           { border-left-color: #d1d5db; opacity: .7; }

.dye-card.card-piaocang {
  background: #fef2f2;
  border-left-color: #ef4444;
  text-align: center;
  font-weight: 800;
  font-size: 16px;
  color: #dc2626;
  padding: 12px 10px;
}

.card-customer {
  font-weight: 700;
  font-size: 13px;
  color: #1e3a5f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-order {
  font-size: 11px;
  color: #475569;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-cardnum {
  font-size: 10px;
  color: #94a3b8;
  font-family: monospace;
}

.card-fabric {
  font-size: 11px;
  color: #6366f1;
  font-weight: 600;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-date {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.card-color {
  font-size: 11px;
  color: #0f766e;
  font-weight: 600;
  margin-top: 2px;
}

.card-vat {
  font-size: 11px;
  color: #7c3aed;
  margin-top: 1px;
}

/* 工卡右上角操作按鈕列 */
.card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 3px;
}

.card-prod-btn,
.card-del-btn {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s, transform .1s;
}
.card-prod-btn:hover, .card-del-btn:hover { opacity: .82; transform: scale(1.1); }

.card-prod-btn          { background: #e2e8f0; color: #64748b; }
.card-prod-btn.prod     { background: #22c55e; color: #fff; }
.card-prod-btn.done     { background: #3b82f6; color: #fff; font-size: 9px; letter-spacing: -1px; }
.card-del-btn           { background: #fee2e2; color: #dc2626; }

/* 漂缸卡內部 */
.piao-text { font-weight: 800; font-size: 15px; color: #dc2626; }

/* SortableJS states */
.dye-card.sortable-ghost  { opacity: .3; background: #bfdbfe; }
.dye-card.sortable-chosen { box-shadow: 0 6px 20px rgba(0,0,0,.22); transform: rotate(1.5deg); }

/* ── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px 28px;
  width: 460px;
  max-width: 96vw;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}

.modal-box h3 {
  font-size: 17px;
  font-weight: 700;
  color: #1e3a5f;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin-bottom: 10px;
}

.form-grid label,
.modal-box label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  gap: 4px;
}

.form-grid label.full-row { grid-column: 1 / -1; }

.form-grid input,
.form-grid select,
.modal-box input,
.modal-box select,
.modal-box textarea {
  padding: 7px 10px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  width: 100%;
  transition: border-color .15s;
}
.form-grid input:focus,
.form-grid select:focus,
.modal-box input:focus,
.modal-box select:focus,
.modal-box textarea:focus { border-color: #3b82f6; }

.modal-box textarea {
  margin-top: 10px;
  resize: vertical;
  width: 100%;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  flex-shrink: 0;
}

.form-err {
  color: #ef4444;
  font-size: 12px;
  min-height: 16px;
  margin-top: 6px;
}

.req { color: #ef4444; }

/* ── Batch scan modal ────────────────────────────────────────── */
#batch-box {
  width: 820px;
  max-width: 96vw;
  height: 560px;
  max-height: 90vh;
  resize: both;
  overflow: hidden;
  min-width: 480px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

#batch-scan-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

#batch-scan {
  flex: 1;
  padding: 9px 14px;
  border: 2px solid #93c5fd;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#batch-scan:focus    { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
#batch-scan.scan-ok  { border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
#batch-scan.scan-err { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.2); }

#batch-scan-hint { font-size: 12px; color: #64748b; min-width: 60px; flex-shrink: 0; }

#batch-list-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  scrollbar-width: thin;
}

#batch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
#batch-table th {
  position: sticky;
  top: 0;
  background: #1e3a5f;
  color: #fff;
  padding: 7px 8px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
#batch-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  white-space: nowrap;
}
#batch-table tr:hover td { background: #f8fafc; }
#batch-table .btn-row-del {
  padding: 2px 8px;
  font-size: 11px;
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
#batch-table .btn-row-del:hover { background: #fca5a5; }

/* ── Modal scan input ────────────────────────────────────────── */
#mc-scan-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

#mc-scan {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid #93c5fd;
  border-radius: 20px;
  font-size: 13px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#mc-scan:focus        { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
#mc-scan.scan-ok      { border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
#mc-scan.scan-err     { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.2); }

#mc-scan-hint {
  font-size: 11px;
  min-width: 60px;
  color: #64748b;
}

/* ── Scan input（待排欄上方）────────────────────────────────── */
#scan-area {
  margin-bottom: 10px;
}

#scan-input {
  width: 185px;
  padding: 8px 12px;
  border: 2px solid #93c5fd;
  border-radius: 20px;
  background: #fff;
  color: #1e3a5f;
  font-size: 13px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}
#scan-input::placeholder { color: #94a3b8; }
#scan-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}
#scan-input.scan-ok  { border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
#scan-input.scan-err { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.2); }

/* ── Master modal ─────────────────────────────────────────────── */
#master-box {
  width: 860px;
  max-width: 96vw;
  height: 600px;
  max-height: 90vh;
  resize: both;
  overflow: hidden;
  min-width: 480px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

#master-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
#master-search {
  flex: 1;
  min-width: 160px;
  padding: 7px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
#master-search:focus { border-color: #3b82f6; }

#master-list-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  scrollbar-width: thin;
}

#master-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
#master-table th {
  position: sticky;
  top: 0;
  background: #1e3a5f;
  color: #fff;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
#master-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  white-space: nowrap;
}
#master-table tr:hover td { background: #f8fafc; }
#master-table .card-num { font-weight: 700; color: #1e3a5f; font-family: monospace; }

/* ── History modal ───────────────────────────────────────────── */
#history-list {
  max-height: 420px;
  overflow-y: auto;
  margin: 4px 0 8px;
  scrollbar-width: thin;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  margin-bottom: 8px;
  transition: background .15s;
}
.history-row:hover { background: #f8fafc; }

.history-info { flex: 1; min-width: 0; }

.history-name {
  font-weight: 700;
  font-size: 14px;
  color: #1e3a5f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta { font-size: 12px; color: #64748b; margin-top: 3px; }
.history-note { font-size: 11px; color: #94a3b8; margin-top: 2px; }

.history-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── 日報產量統計 ─────────────────────────────────────────────── */
.prod-date-input {
  padding: 5px 9px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 7px;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.prod-date-input:focus { border-color: rgba(255,255,255,.7); }

#prod-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* 數字卡片列 */
#prod-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.prod-card {
  flex: 1;
  min-width: 110px;
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
  border-top: 4px solid #3b82f6;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.prod-card:nth-child(1) { border-color: #3b82f6; }
.prod-card:nth-child(2) { border-color: #8b5cf6; }
.prod-card:nth-child(3) { border-color: #06b6d4; }
.prod-card:nth-child(4) { border-color: #22c55e; }
.prod-card:nth-child(5) { border-color: #f59e0b; }
.prod-card-pending      { border-color: #ef4444 !important; }
.pc-label { font-size: 12px; color: #64748b; font-weight: 600; }
.pc-value { font-size: 24px; font-weight: 800; color: #1e3a5f; letter-spacing: -.5px; }
.pc-unit  { font-size: 11px; color: #94a3b8; }

/* 圖表區 */
#prod-chart-wrap {
  background: #fff;
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
}
#prod-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
#prod-chart-title { font-size: 14px; font-weight: 700; color: #1e3a5f; }
#prod-chart-toggle { display: flex; gap: 4px; }
.chart-tab {
  padding: 4px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  font-size: 12px;
  cursor: pointer;
  color: #475569;
  font-weight: 600;
  transition: background .15s;
}
.chart-tab.active { background: #1e3a5f; color: #fff; border-color: #1e3a5f; }
#prod-chart-container { height: 280px; position: relative; }

/* 資料表格 */
#prod-table-wrap {
  background: #fff;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
  overflow: hidden;
}
#prod-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
#prod-table th {
  background: #1e3a5f;
  color: #fff;
  padding: 10px 12px;
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
}
#prod-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  text-align: center;
  color: #334155;
}
#prod-table tr:last-child td { border-bottom: none; }
#prod-table tr:hover td { background: #f8fafc; }
#prod-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
#prod-table th.col-pending,
#prod-table td.col-pending { color: #94a3b8; }
#prod-table th.col-pending { background: #2d4a6e; }
.total-row td {
  background: #f1f5f9 !important;
  font-weight: 700;
  color: #1e3a5f !important;
  border-top: 2px solid #cbd5e1;
}

/* ── Toast ───────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e3a5f;
  color: #fff;
  padding: 10px 22px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
  z-index: 200;
  white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ── 使用者管理 ──────────────────────────────────────────────── */
#admin-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 28px;
}
#user-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
  font-size: 13px;
}
#user-table th {
  background: #1e3a5f;
  color: #fff;
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
#user-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}
#user-table tr:last-child td { border-bottom: none; }
#user-table tr:hover td { background: #f8fafc; }
#user-table .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; color: #1e3a5f; }

.mod-tag {
  display: inline-block;
  background: #eef2ff;
  color: #4338ca;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  margin: 2px 3px 2px 0;
}
.mod-tag.mod-all { background: #dcfce7; color: #15803d; }

.badge { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 10px; }
.badge-on  { background: #dcfce7; color: #15803d; }
.badge-off { background: #fee2e2; color: #b91c1c; }

/* 編輯 / 新增 Modal 內的模組勾選
   （用 .modal-box 前綴提高優先級，覆寫全域 label/input 樣式）*/
.u-section-label { font-size: 13px; font-weight: 600; color: #475569; margin: 6px 0 6px; }
#u-modules-wrap { margin: 12px 0 4px; }
#u-modules { display: flex; flex-direction: column; gap: 8px; }
.modal-box label.u-mod-item {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 14px; font-weight: 500; color: #334155; cursor: pointer;
  padding: 9px 12px; border: 1px solid #e2e8f0; border-radius: 8px;
}
.modal-box label.u-mod-item:hover { border-color: #93c5fd; background: #f8fafc; }
.modal-box label.u-checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 13px; font-weight: 500; color: #475569; margin-top: 12px; cursor: pointer;
}
.modal-box label.u-mod-item input[type=checkbox],
.modal-box label.u-checkbox-row input[type=checkbox] {
  width: 18px; height: 18px; flex: 0 0 18px; margin: 0; cursor: pointer;
}

.menu-item-admin { margin-top: 6px; border-top: 1px solid rgba(255,255,255,.12); padding-top: 6px; }
