* { box-sizing: border-box; }
body {
  font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: #faf7f5;
  color: #333;
  margin: 0 auto;
  padding: 0 16px 40px;
  max-width: 1200px;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 2px solid #f2c9d4;
  margin-bottom: 20px;
}
header h1 { font-size: 20px; margin: 0; color: #d1487a; }
header .who { font-size: 14px; color: #777; }
header form { display: inline; margin-left: 12px; }
a { color: #d1487a; }
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 16px;
  margin-bottom: 12px;
}
.node-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.node-row .no {
  font-weight: bold;
  color: #d1487a;
  width: 24px;
}
.node-row .name { flex: 1; font-size: 16px; }
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: bold;
}
.badge.pending { background: #eee; color: #888; }
.badge.in_progress { background: #fff2cc; color: #a67c00; }
.badge.done { background: #d9f2e3; color: #1e8a4c; }
.badge.exception { background: #fbdcdc; color: #c62828; }
.meta { font-size: 13px; color: #999; margin-top: 4px; }
form.login-box {
  max-width: 320px;
  margin: 80px auto;
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.1);
}
form.login-box h1 { text-align: center; color: #d1487a; font-size: 22px; }
input, select, textarea, button {
  font-size: 15px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #ddd;
  width: 100%;
  margin-top: 6px;
}
label { font-size: 14px; color: #555; display: block; margin-top: 12px; }
button.primary, input[type=submit] {
  background: #d1487a;
  color: #fff;
  border: none;
  margin-top: 16px;
  cursor: pointer;
  font-weight: bold;
}
.error { color: #c62828; margin-top: 10px; font-size: 14px; }
.success { color: #1e8a4c; margin-top: 10px; font-size: 14px; }
.change-password-link { font-size: 13px; margin-left: 12px; color: #777; text-decoration: underline; }
.status-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.status-form button {
  width: auto;
  padding: 8px 14px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  color: #444;
}
.status-form button.active { border-color: #d1487a; color: #d1487a; font-weight: bold; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid #eee; font-size: 14px; }
.item-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; align-items: flex-end; }
.item-form > div { flex: 1; min-width: 100px; }
.item-form button { width: auto; padding: 8px 16px; }
.back-link { display: inline-block; margin-bottom: 12px; }
.del-btn { width: auto; padding: 4px 10px; font-size: 12px; background: #fbdcdc; border: none; color: #c62828; }

/* ===== 營運流程頁 ===== */
.flow-summary-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.ops-id { font-size: 12px; color: #999; letter-spacing: 0.5px; }
.flow-summary h2 { margin: 4px 0 0; font-size: 20px; color: #333; }
.progress-wrap { min-width: 200px; }
.progress-label { font-size: 13px; color: #666; margin-bottom: 6px; text-align: right; }
.progress-bar { width: 220px; height: 10px; background: #eee; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #f2a7c0, #d1487a); border-radius: 999px; transition: width 0.3s; }

.my-tasks { margin-top: 16px; padding-top: 14px; border-top: 1px dashed #eee; }
.my-tasks-label { font-size: 13px; color: #999; margin-bottom: 8px; }
.my-task-chip {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  text-decoration: none;
  margin: 0 8px 8px 0;
  border: 1px solid #ddd;
  color: #444;
}
.my-task-chip.status-in_progress { background: #fff2cc; border-color: #e6c368; color: #8a6400; }
.my-task-chip.status-exception { background: #fbdcdc; border-color: #eaa; color: #c62828; }
.my-task-chip.status-pending { background: #f5f5f5; color: #888; }

.flow-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-top: 20px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.flow-card {
  flex: 1;
  min-width: 130px;
  text-decoration: none;
  border-radius: 10px;
  border: 2px solid #eee;
  padding: 12px 10px;
  background: #fafafa;
  color: #333;
  transition: all 0.15s;
}
.flow-card:hover { border-color: #d1487a; }
.flow-card.active { border-color: #d1487a; box-shadow: 0 0 0 3px rgba(209,72,122,0.15); }
.flow-card-step { font-size: 11px; color: #aaa; font-weight: bold; letter-spacing: 0.5px; }
.flow-card-name { font-size: 15px; font-weight: bold; margin: 4px 0 2px; }
.flow-card-role { font-size: 12px; color: #888; }
.flow-card-status { font-size: 13px; margin-top: 8px; font-weight: bold; }
.flow-arrow { display: flex; align-items: center; justify-content: center; color: #ccc; width: 20px; flex-shrink: 0; }

.flow-card.status-pending { background: #fafafa; }
.flow-card.status-waiting { background: #eef4fb; }
.flow-card.status-waiting .flow-card-status { color: #3d7ab8; }
.flow-card.status-in_progress { background: #fffaf0; border-color: #e6c368; }
.flow-card.status-in_progress .flow-card-status { color: #a67c00; }
.flow-card.status-done { background: #f2faf5; border-color: #bfe6cd; }
.flow-card.status-done .flow-card-status { color: #1e8a4c; }
.flow-card.status-exception { background: #fdf3f3; border-color: #eaa; }
.flow-card.status-exception .flow-card-status { color: #c62828; }

.badge.waiting { background: #eef4fb; color: #3d7ab8; }

.detail-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-header h2 { margin: 0; font-size: 19px; }
.waiting-notice { background: #eef4fb; color: #3d7ab8; padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-top: 12px; }
.export-reminder { background: #fff8e1; color: #8a6400; padding: 8px 14px; border-radius: 8px; font-size: 13px; margin-top: 8px; }

.store-checklist { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.store-checklist form { width: auto; margin: 0; }
.store-btn {
  width: auto;
  padding: 10px 16px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  color: #444;
}
.store-btn.confirmed { background: #d9f2e3; border-color: #bfe6cd; color: #1e8a4c; font-weight: bold; }
.meta-inline { font-size: 11px; color: #999; margin-left: 6px; }

.exception-details { margin-top: 14px; }
.exception-details summary { cursor: pointer; color: #c62828; font-size: 14px; font-weight: bold; }
.exception-form { margin-top: 10px; padding: 12px; background: #fdf3f3; border-radius: 8px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; }
.danger-btn { width: auto; padding: 8px 16px; background: #c62828; color: #fff; border: none; margin-top: 14px; }

.note-form { margin-top: 14px; }
.rollback-tag { display: inline-block; margin-left: 8px; font-size: 11px; background: #fbdcdc; color: #c62828; padding: 2px 8px; border-radius: 999px; }

.event-log { list-style: none; padding: 0; margin: 8px 0 0; }
.event-log li { padding: 8px 0; border-bottom: 1px solid #f2f2f2; font-size: 13px; color: #444; }
.event-time { color: #999; margin-right: 10px; font-variant-numeric: tabular-nums; }
.event-note { color: #777; margin-top: 4px; font-size: 12px; }

.item-group { margin-top: 14px; }
.item-group-time {
  font-size: 12px;
  color: #999;
  background: #f5f5f5;
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.item-group table { margin-top: 4px; }

.check-btn {
  width: auto;
  padding: 4px 10px;
  font-size: 16px;
  background: none;
  border: none;
  cursor: pointer;
}
.status-form button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== 節點4 到貨／驗收／配單 ===== */
.receiving-summary {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  background: #f8f5f4;
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 14px;
  font-size: 14px;
  color: #555;
}
.receiving-summary strong { font-size: 16px; color: #333; }
.danger-text { color: #c62828 !important; }
.product-group { margin-top: 18px; }
.product-group h3 { margin-bottom: 4px; }
.inline-form, .allocation-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; width: auto; }
.allocation-form label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; margin: 4px 6px 0 0; width: auto; }
.allocation-form input, .inline-form input { margin-top: 0; }
.small-btn { width: auto; padding: 6px 10px; font-size: 13px; margin-top: 0; }
td details { margin: 0; }
td details summary { cursor: pointer; }
td .exception-form { display: flex; gap: 6px; margin-top: 6px; padding: 8px; }
td .exception-form select, td .exception-form input { width: auto; margin-top: 0; }

.matrix-cell { text-align: center; }
.carried-tag { display: inline-block; margin-left: 6px; font-size: 11px; background: #fff2cc; color: #8a6400; padding: 2px 8px; border-radius: 999px; }
.store-block { border-bottom: 1px solid #f2f2f2; padding: 10px 0; }
.store-block:last-child { border-bottom: none; }
.allocation-list { list-style: none; padding: 0; margin: 8px 0 0 4px; font-size: 13px; color: #555; }
.allocation-list li { padding: 3px 0; }

@media (max-width: 760px) {
  .flow-row { flex-direction: column; }
  .flow-arrow { transform: rotate(90deg); width: auto; height: 16px; }
  .flow-card { min-width: 0; }
}

/* ===== 考勤 ===== */
.att-title { margin: 0 0 12px; font-size: 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.month-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; width: auto; }
.month-form input { width: auto; margin-top: 0; }
.punch-state { font-size: 16px; margin: 4px 0 14px; }
.punch-state.warn { color: #c62828; }
.punch-buttons { display: flex; gap: 14px; flex-wrap: wrap; }
.punch-buttons form { margin: 0; width: auto; }
.big-btn { width: auto; min-width: 150px; padding: 16px 28px; font-size: 18px; font-weight: bold; border: none; border-radius: 12px; color: #fff; cursor: pointer; margin-top: 0; }
.big-btn.in { background: #1e8a4c; }
.big-btn.out { background: #d1487a; }
.big-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.flash-ok { background: #d9f2e3; color: #1e8a4c; }
.flash-error { background: #fbdcdc; color: #c62828; }
.req-form { margin-bottom: 8px; }
.req-form summary { cursor: pointer; font-weight: bold; padding: 6px 0; }
.req-status { font-size: 12px; font-weight: bold; padding: 2px 8px; border-radius: 999px; background: #eee; color: #666; }
.req-status.pending { background: #fff2cc; color: #a67c00; }
.req-status.approved { background: #d9f2e3; color: #1e8a4c; }
.req-status.rejected { background: #fbdcdc; color: #c62828; }

/* ===== 首頁／登入頁 ===== */
.site-title { color: inherit; text-decoration: none; }
.page-narrow { max-width: 900px; margin: 0 auto; padding-top: 24px; }
.hero { position: relative; border-radius: 16px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.15); margin-bottom: 20px; background: #dc6260; }
.hero img { display: block; width: 100%; height: auto; }
.hero-title {
  position: absolute; left: 63%; right: 2%; top: 50%; transform: translateY(-50%);
  text-align: center; color: #fff; font-weight: bold; line-height: 1.35;
  font-size: clamp(15px, 3.8vw, 44px); letter-spacing: 2px; text-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.page-narrow .login-box { margin: 0 auto 40px; }
.welcome { font-size: 16px; color: #555; margin: 4px 0 16px; }
.status-strip { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 40px; }
.status-chip { display: inline-block; background: #fff; border-radius: 999px; padding: 10px 18px; font-size: 14px; color: #444; text-decoration: none; box-shadow: 0 1px 4px rgba(0,0,0,0.1); border: 2px solid transparent; }
.status-chip:hover { border-color: #d1487a; }

.salary { color: #1e8a4c; font-size: 16px; }

/* 圖片上的可點擊熱區（位置用百分比，跟著圖片縮放） */
.hotspot { position: absolute; display: block; padding: 0; margin: 0; border: 0; border-radius: 16px; background: transparent; cursor: pointer; appearance: none; }
.hotspot:hover, .hotspot:focus-visible { background: rgba(255,255,255,0.14); outline: 2px solid rgba(255,255,255,0.75); }
.hotspot.disabled { cursor: default; pointer-events: auto; }
.hotspot.disabled:hover { background: transparent; outline: none; }
.hs-flow { left: 3.5%; top: 50%; width: 27%; height: 41%; }
.hs-att { left: 36%; top: 50%; width: 21%; height: 41%; }
.hs-wish { left: 71%; top: 48%; width: 24%; height: 43%; }

/* ===== 許願池 ===== */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.wish-form label { margin-top: 12px; }
.wish-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f2f2f2; }
.wish-item:last-child { border-bottom: none; }
.wish-main { flex: 1; min-width: 0; }
.wish-name { font-weight: bold; font-size: 16px; }
.wish-note { font-size: 13px; color: #777; margin-top: 4px; word-break: break-word; }
.wish-item form { margin: 0; width: auto; }
.vote-btn { width: auto; min-width: 84px; padding: 8px 14px; border: 2px solid #d1487a; background: #fff; color: #d1487a; border-radius: 999px; font-weight: bold; cursor: pointer; margin-top: 0; white-space: nowrap; font-size: 14px; }
.vote-btn.voted { border-color: #ddd; color: #999; background: #f8f8f8; cursor: default; text-align: center; }
.vote-count { margin-left: 4px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.status-chip.active { border-color: #d1487a; font-weight: bold; }

/* ===== 請假行事曆 ===== */
.cal-nav { display: inline-flex; align-items: center; gap: 12px; font-size: 16px; }
.cal-nav a { text-decoration: none; padding: 2px 10px; border-radius: 8px; background: #f5f5f5; }
.cal-scroll { overflow-x: auto; }
.cal { table-layout: fixed; width: 100%; min-width: 560px; border-collapse: collapse; margin-top: 8px; }
.cal th { text-align: center; background: #faf1f4; color: #d1487a; padding: 6px 0; border: 1px solid #f0dce3; }
.cal td.cal-cell { border: 1px solid #eee; vertical-align: top; height: 92px; padding: 4px; background: #fff; }
.cal td.cal-cell.empty { background: #faf8f7; }
.cal td.cal-cell.today { background: #fff8e1; }
.cal-day { font-size: 12px; color: #999; margin-bottom: 3px; }
.cal-leave { font-size: 11px; line-height: 1.35; background: #fde6ee; border: 1px solid #f2a7c0; border-radius: 6px; padding: 2px 5px; margin-bottom: 3px; word-break: break-all; }
.cal-leave.pending { background: #fff; border-style: dashed; }
.cal-leave.mine { border-color: #d1487a; }
.cal-leave span { display: block; color: #777; }
.cal-leave .cal-type { color: #d1487a; }

.cal-list-title { margin: 18px 0 4px; font-size: 15px; }
@media (max-width: 600px) {
  .cal { min-width: 0; }
  .cal td.cal-cell { height: 60px; padding: 2px; }
  .cal-leave { font-size: 10px; padding: 1px 3px; }
  .cal-leave span { display: none; }
  .cal-day { font-size: 10px; }
}

.cal-list td:nth-child(2), .cal-list td:nth-child(4) { white-space: nowrap; }

/* ===== 商品中心 ===== */
.product-search { display: flex; gap: 8px; margin-top: 12px; }
.product-search input[type=search] { flex: 1; margin-top: 0; }
.product-search button { width: auto; margin-top: 0; padding: 8px 20px; }
.table-scroll { overflow-x: auto; }
.product-table { min-width: 720px; }
.product-table .stopped-row { color: #999; }
.stock-table { min-width: 980px; }
.stock-table td { vertical-align: top; }
.stock-table details form { margin-top: 6px; }
.expiry-30-tag { display: inline-block; background: #fff7d6; color: #8a6d00; border-radius: 999px; padding: 1px 8px; font-size: 11px; margin-left: 4px; }
.product-tabs { display: flex; gap: 8px; margin: 4px 0 12px; }
.product-tabs .tab { padding: 8px 18px; border-radius: 999px; background: #fff; color: #555; text-decoration: none; font-size: 14px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); border: 2px solid transparent; }
.product-tabs .tab:hover { border-color: #d1487a; }
.product-tabs .tab.active { background: #d1487a; color: #fff; font-weight: bold; }
.ordered-cell { min-width: 230px; }
.ordered-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.ordered-row input { width: 72px; margin-top: 0; padding: 4px 8px; }
.ordered-name { font-size: 13px; }
.ordered-total { font-size: 13px; margin: 6px 0; }
.temp-password-card { border: 2px solid #d1487a; }
.temp-password { font-size: 26px; letter-spacing: 3px; font-family: ui-monospace, Menlo, monospace; background: #fff2cc; padding: 4px 12px; border-radius: 8px; user-select: all; }

/* ===== 固定頁首＋使用者選單 ===== */
header.site-header { position: sticky; top: 0; z-index: 50; background: #faf7f5; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; background: #fff; border: 1px solid #f2c9d4; border-radius: 999px; padding: 7px 16px; font-size: 14px; color: #444; user-select: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu[open] summary { border-color: #d1487a; }
.menu-badge { display: inline-block; margin-left: 6px; background: #d1487a; color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; }
.user-menu-list { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: #fff; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,0.15); padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.user-menu-list a { padding: 10px 12px; border-radius: 8px; text-decoration: none; color: #333; font-size: 14px; }
.user-menu-list a:hover { background: #fdeef3; }
.user-menu-list form { margin: 6px 0 0; display: block; }
.user-menu-list button { width: 100%; margin: 0; background: #f5f5f5; border: 1px solid #ddd; }

/* ===== 商品中心：直接登錄現貨／效期 ===== */
.stock-entry { margin-top: 4px; }
.stock-entry summary { cursor: pointer; font-size: 12px; color: #d1487a; list-style: none; }
.stock-entry summary::-webkit-details-marker { display: none; }
.stock-entry-form { margin-top: 6px; padding: 10px; background: #fff7fa; border: 1px solid #f2c9d4; border-radius: 10px; min-width: 260px; }
.stock-entry-form .se-title { font-size: 13px; font-weight: bold; margin-bottom: 6px; }
.stock-entry-form .se-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 10px; }
.stock-entry-form label { margin-top: 0; font-size: 12px; }
.stock-entry-form input { margin-top: 2px; padding: 5px 8px; }
.stock-entry-form .se-expiry { margin-top: 8px; display: block; }
.stock-entry-form button { margin-top: 8px; }
/* ===== 首頁效期提醒 ===== */
.expiry-alert { border-left: 5px solid #e6b800; }
.expiry-alert.has-expired { border-left-color: #c62828; }
.expiry-alert-title a { margin-left: 10px; font-size: 13px; }
.expiry-alert ul { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.expiry-alert li { margin-bottom: 4px; }
/* ===== 行事曆上的效期 ===== */
.cal-expiry { font-size: 11px; line-height: 1.3; border-radius: 6px; padding: 2px 5px; margin-bottom: 3px; word-break: break-all; border: 1px solid; }
.cal-expiry.expired { background: #fbdcdc; border-color: #e57373; color: #b71c1c; }
.cal-expiry.soon { background: #fff2cc; border-color: #e6b800; color: #8a6400; }
.cal-expiry.soon30 { background: #fff7d6; border-color: #f0dc8a; color: #8a6d00; }
.cal-expiry.more { background: #f5f5f5; border-color: #ddd; color: #777; }
.stock-entry-form .se-reserved { margin-top: 8px; }
.stock-entry-form .se-reserved summary { font-size: 12px; color: #777; cursor: pointer; }
.stock-entry-form .se-reserved .se-grid { margin-top: 6px; }
