:root {
  --bg: #F7F9F6; --surface: #FFFFFF; --ink: #1C2B22; --muted: #5A6B60;
  --line: #DCE4DD; --accent: #1B6E4B; --accent-dark: #145238; --accent-soft: #E7F2EC;
  --warn: #C97B12; --warn-soft: #FBF1E2; --bad: #B3382E; --bad-soft: #F9E8E6;
  --info: #2C6E9B; --info-soft: #E6F0F7;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Leelawadee UI", "Segoe UI", "Noto Sans Thai", "Sarabun", sans-serif;
  font-size: 16px; line-height: 1.6;
}
.container { max-width: 1040px; margin: 0 auto; padding: 16px 14px 90px; }
h1 { font-size: 22px; margin: 10px 0 14px; }
h2 { font-size: 17px; }
h3 { font-size: 16px; margin: 0 0 8px; }
a { color: var(--accent-dark); }
.muted { color: var(--muted); font-size: 0.92em; }
.num { font-variant-numeric: tabular-nums; }
code { background: var(--accent-soft); border-radius: 4px; padding: 1px 5px; font-size: 0.88em; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--accent); color: #fff; padding: 10px 16px;
  position: sticky; top: 0; z-index: 50;
}
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 18px; }
.brand span { font-weight: 400; opacity: 0.85; }
.nav-links { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav-links a { color: #fff; text-decoration: none; padding: 4px 10px; border-radius: 6px; font-size: 15px; }
.nav-links a:hover { background: rgba(255,255,255,0.15); }
.bell { position: relative; }
.badge {
  position: absolute; top: -4px; right: -2px; background: #E5484D; color: #fff;
  border-radius: 999px; font-size: 11px; min-width: 17px; height: 17px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; font-weight: 700;
}
.nav-user { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.uname { opacity: 0.9; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline { display: inline; }

/* ---------- flash / callout ---------- */
.flash { padding: 10px 14px; border-radius: 8px; margin: 12px 0; font-weight: 600; }
.flash-success { background: var(--accent-soft); color: var(--accent-dark); border: 1px solid var(--accent); }
.flash-error { background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad); }
.flash-warn, .flash-info { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); }
.callout-warn {
  background: var(--warn-soft); border-left: 4px solid var(--warn);
  border-radius: 0 8px 8px 0; padding: 12px 14px; margin: 14px 0;
}

/* ---------- cards / pills / buttons ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 12px 0; }
.pill {
  display: inline-block; background: #EDF1EC; color: var(--muted); border-radius: 999px;
  padding: 1px 10px; font-size: 13px; font-weight: 600; margin: 2px 2px 2px 0;
}
.pill-ok { background: var(--accent-soft); color: var(--accent-dark); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-info { background: var(--info-soft); color: var(--info); }
.btn {
  display: inline-block; border: none; border-radius: 8px; padding: 10px 18px;
  font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none; text-align: center;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-ghost {
  background: transparent; border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; font-family: inherit; font-size: 14px;
}
.btn-ghost:hover { background: var(--accent-soft); }
.btn-block { width: 100%; }
.btn-xs { padding: 2px 8px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.backlink { display: inline-block; margin: 4px 0; text-decoration: none; font-size: 14px; }
.week-tag { font-size: 14px; color: var(--accent-dark); background: var(--accent-soft); border-radius: 999px; padding: 3px 12px; vertical-align: middle; }

/* ---------- forms ---------- */
label { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 14px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 15px; background: var(--surface); color: var(--ink); margin: 4px 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
/* checkbox/radio ต้องอยู่บรรทัดเดียวกับข้อความ — ไม่กินความกว้างเต็มแถวแบบ input ทั่วไป */
input[type="checkbox"], input[type="radio"] { width: auto; margin: 0 6px 0 0; vertical-align: middle; }
.input-sm { max-width: 200px; }
.input-xs { max-width: 110px; display: inline-block; padding: 4px 8px; font-size: 13px; margin: 0 4px; }
.form-grid input, .form-grid select { margin: 5px 0; }
.comment-input { font-size: 14px; background: #FBFCFA; }

/* ---------- login ---------- */
.login-box { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login-title { font-size: 34px; color: var(--accent); margin: 0; }
.login-title span { color: var(--ink); font-weight: 400; }
.login-sub { color: var(--muted); margin: 6px 0 18px; }
.login-box .card { text-align: left; }

/* ---------- FC home ---------- */
.store-list { display: flex; flex-direction: column; gap: 10px; }
.store-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap;
}
.store-name { font-weight: 700; font-size: 16px; }
.store-action { flex-shrink: 0; }

/* ---------- checklist ---------- */
.cat-head {
  margin: 26px 0 8px; color: var(--accent-dark); border-bottom: 2px solid var(--accent-soft);
  padding-bottom: 4px; font-size: 17px;
}
.item-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 8px 0; }
.item-title { font-weight: 600; }
.item-desc { color: var(--muted); font-size: 13.5px; margin: 2px 0 6px; }
.req { color: var(--bad); font-weight: 800; }
.radio-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 4px; }
.radio-opt {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 500; font-size: 14.5px; margin: 0;
}
.radio-opt:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 700; }
.radio-opt input { width: auto; margin: 0; }
.score-opt { min-width: 46px; justify-content: center; }
.sticky-actions {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface);
  border-top: 1px solid var(--line); padding: 10px 14px; display: flex; gap: 10px;
  justify-content: center; z-index: 40; box-shadow: 0 -2px 10px rgba(28,43,34,0.08);
}
.sticky-actions .btn { flex: 1; max-width: 220px; }
.extra-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.extra-form input { margin: 4px 0; }

/* ---------- view / review ---------- */
.meta-card > div { margin: 4px 0; }
.flag-row { margin-top: 6px; }
.view-item { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.view-item .item-title { flex: 1 1 260px; }
.item-answer { text-align: right; flex: 1 1 180px; }
.item-flag { border-left: 4px solid var(--bad); }
.review-item { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 8px 0; }
.review-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.review-actions { border: 2px solid var(--accent); }
.queue-card {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; margin: 10px 0; text-decoration: none; color: var(--ink); flex-wrap: wrap;
}
.queue-card:hover { border-color: var(--accent); }
.row-item { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.audit-box { margin: 20px 0; color: var(--muted); font-size: 13.5px; }
.audit-box summary { cursor: pointer; font-weight: 600; }
.audit-row { padding: 4px 0; border-bottom: 1px dashed var(--line); word-break: break-all; }

/* ---------- notifications ---------- */
.notif-item { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 8px 0; }
.notif-item:not(.notif-unread) { opacity: .72; } /* อ่านแล้วจางลง — รายการใหม่เด่นกว่า */
.notif-unread { border-left: 4px solid var(--accent); background: var(--accent-soft); }
.notif-title { font-weight: 600; }
.notif-time { font-size: 12.5px; }

/* ---------- dashboard ---------- */
.dash-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.dash-head select { width: auto; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 14px 0; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 10px; text-align: center; text-decoration: none; color: var(--ink);
}
.kpi-warn { border-color: var(--warn); background: var(--warn-soft); }
.kpi-link:hover { border-color: var(--accent); }
.kpi-num { font-size: 28px; font-weight: 800; color: var(--accent-dark); font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 13px; color: var(--muted); line-height: 1.35; }
.bar { display: inline-block; width: 90px; height: 10px; background: #EDF1EC; border-radius: 999px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-ok { background: var(--accent); }
.bar-mid { background: var(--warn); }
.bar-low { background: var(--bad); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin: 12px 0; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th { text-align: left; font-size: 12.5px; color: var(--muted); background: #F0F4F0; padding: 8px 12px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.heat-table td.heat-cell { width: 34px; height: 26px; background: #EDF1EC; border: 2px solid var(--surface); border-radius: 4px; }
.h-ok { background: var(--accent) !important; }
.h-mid { background: var(--warn) !important; }
.h-bad { background: var(--bad) !important; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- checklist tabs ---------- */
.tab-bar {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 8px;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.tab-btn {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 7px 14px 7px 8px; font-family: inherit;
  font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tab-btn .tab-no {
  background: #EDF1EC; color: var(--muted); border-radius: 50%;
  width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.tab-btn .tab-count { font-size: 11.5px; color: var(--muted); }
.tab-btn.tab-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-btn.tab-active .tab-no { background: rgba(255,255,255,0.25); color: #fff; }
.tab-btn.tab-active .tab-count { color: rgba(255,255,255,0.85); }
.tab-btn.tab-done .tab-no { background: var(--accent-soft); color: var(--accent-dark); }
.tab-btn.tab-done .tab-count { color: var(--accent-dark); font-weight: 800; }
.tab-btn.tab-done.tab-active .tab-count { color: #fff; }
.tab-hidden { display: none; }
.tab-nav { display: flex; justify-content: space-between; gap: 10px; margin: 12px 0; }
.tab-nav button:disabled { opacity: 0.4; cursor: default; }

/* ---------- checklist category sections ---------- */
.cat-section {
  border: 1.5px solid var(--line); border-left: 5px solid var(--accent);
  border-radius: 12px; margin: 18px 0; background: var(--surface); overflow: hidden;
}
.cat-section-head {
  background: var(--accent-soft); color: var(--accent-dark);
  padding: 10px 14px; font-weight: 800; font-size: 16px;
  display: flex; align-items: center; gap: 10px;
}
.cat-no {
  background: var(--accent); color: #fff; border-radius: 50%;
  width: 26px; height: 26px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-variant-numeric: tabular-nums;
}
.cat-section-body { padding: 8px 10px 10px; }
.cat-comment-label { font-weight: 600; font-size: 14px; margin: 10px 4px 4px; display: block; }
.cat-comment-label textarea { background: #FBFCFA; font-size: 14px; }
.cat-comment-view {
  background: var(--accent-soft); border-radius: 8px; padding: 8px 12px;
  margin: 8px 0 4px; font-size: 14.5px;
}
.cause-label { font-size: 13.5px; margin-top: 6px; }
.oos-wrap { margin-top: 6px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; }
/* ข้อเงินชำรุด (cash_damage) — 3 กล่อง: เหรียญดำ / แบงค์ชำรุด / เงินลอย */
.cash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-top: 6px; }
.cash-box { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.cash-box-title { font-weight: 700; font-size: 13.5px; color: var(--accent-dark); margin-bottom: 2px; }
.cash-box .sku-row { margin: 4px 0; font-size: 13.5px; }
.cash-box input[type=text], .cash-box input:not([type]) { font-size: 13.5px; padding: 6px 8px; }
.defect-wrap, .other-wrap { margin-top: 4px; }
.defect-input { border-color: var(--bad); background: var(--bad-soft); font-size: 14px; }
.defect-input::placeholder { color: var(--bad); opacity: 0.7; }
.final-sub { color: var(--accent-dark); font-size: 15.5px; margin: 14px 4px 6px; border-bottom: 1px dashed var(--line); padding-bottom: 4px; }
.sku-row { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 6px 0 2px; }
.sku-input { width: 90px; text-align: center; font-weight: 700; }
.sku-bad { color: var(--bad); }
.cat-section-body .item-card { border-color: #EDF1EC; margin: 6px 0; }
.item-no { color: var(--accent-dark); font-weight: 800; margin-right: 8px; }

/* ---------- calendar ---------- */
.cal-box { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 12px 0; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.cal-title { font-weight: 800; font-size: 17px; color: var(--accent-dark); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 3px; }
.cal-dayname { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding: 2px 0; }
.cal-cell {
  min-height: 64px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px;
  text-decoration: none; color: var(--ink); display: block; overflow: hidden; background: var(--surface);
}
.cal-cell:hover { border-color: var(--accent); background: var(--accent-soft); }
.cal-empty { border: none; background: transparent; }
.cal-empty:hover { border: none; background: transparent; }
.cal-today { border: 2px solid var(--accent); background: var(--accent-soft); }
.cal-past { opacity: 0.75; }
.cal-daynum { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.cal-today .cal-daynum { color: var(--accent-dark); }
.cal-chip {
  display: block; font-size: 10.5px; line-height: 1.35; border-radius: 4px; padding: 1px 4px;
  margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600;
}
.chip-pending { background: var(--warn-soft); color: var(--warn); }
.chip-confirmed { background: var(--accent-soft); color: var(--accent-dark); }
.chip-rejected { background: var(--bad-soft); color: var(--bad); }
.cal-more { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.cal-week-selected { position: relative; border-left: 4px solid var(--accent); margin-left: -4px; border-radius: 6px; }
.cal-week-selected .cal-cell { background: var(--accent-soft); }
.cal-week-selected .cal-cell.cal-empty { background: transparent; }
.cal-week-selected .cal-today { border: 2px solid var(--accent); }
.cal-legend { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; }
.cal-legend .cal-chip { display: inline-block; margin: 0; }
@media (max-width: 560px) {
  .cal-cell { min-height: 48px; padding: 2px 3px; }
  .cal-chip { font-size: 9px; }
}

/* ---------- plan forms ---------- */
.store-check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; margin: 8px 0; }
.store-check { justify-content: flex-start; }
.decide-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.decide-form input { margin: 0; }
.btn-reject { color: var(--bad); border-color: var(--bad); }

/* ---------- home layout: งานของฉัน (ซ้าย) · ปฏิทิน+งานวันนี้ (กลาง) · สาขา (ขวา) ---------- */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.home-grid3 { display: grid; grid-template-columns: 250px minmax(0, 1fr) 290px; gap: 18px; align-items: start; }
.home-tasks { position: sticky; top: 62px; max-height: calc(100vh - 80px); overflow-y: auto; margin-top: 12px; }
.task-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 12px;
}
/* การ์ดงานที่ต้องดำเนินการ — เหนือปฏิทินในคอลัมน์หลัก (แสดงเฉพาะงานค้าง จึงสั้นเสมอ) */
.notify-card { margin: 12px 0 4px; }
.task-head {
  font-weight: 800; font-size: 14.5px; color: var(--accent-dark); margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 6px;
}
.task-more { font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.task-big { font-size: 26px; font-weight: 800; color: var(--accent-dark); line-height: 1.2; }
.task-unit { font-size: 14px; font-weight: 600; color: var(--muted); }
.bar-wide { width: 100%; height: 8px; margin: 6px 0 4px; display: block; }
.task-row {
  display: block; padding: 7px 8px; margin: 4px -4px; border-radius: 8px;
  font-size: 13.5px; line-height: 1.45; color: var(--ink); text-decoration: none;
}
a.task-row:hover { background: var(--accent-soft); }
.task-urgent { background: var(--warn-soft); }
.task-urgent:hover { background: var(--bad-soft); }
.task-notif { border-top: 1px dashed var(--line); border-radius: 0; margin: 0 -4px; }
.task-notif:first-of-type { border-top: none; }
.task-unread { font-weight: 700; }
.task-time { display: block; font-size: 11.5px; font-weight: 400; }
@media (max-width: 1100px) {
  .home-grid3 { grid-template-columns: 1fr; }
  .home-tasks { position: static; max-height: none; }
  .home-grid3 .home-side { position: static; max-height: none; }
}
.home-side {
  /* คอลัมน์ขวา: การ์ดแต่ละใบแยกกรอบชัดเจน มีช่องว่างระหว่างกัน (ผู้ใช้ขอ 2026-08-23) */
  background: transparent; border: none; padding: 0 2px 0 0; position: sticky; top: 62px;
  max-height: calc(100vh - 80px); overflow-y: auto;
  margin-top: 12px; /* แนวเดียวกับกรอบปฏิทิน (.cal-box margin 12px) */
}
.side-head { margin: 2px 0 2px; font-size: 15.5px; color: var(--accent-dark); }
.home-side .task-card {
  margin: 0 0 16px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 14px;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.home-side .task-card:last-child { margin-bottom: 0; }
.home-side .task-head { border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 10px; }
.side-day {
  font-weight: 800; font-size: 13px; color: var(--accent-dark);
  background: var(--accent-soft); border-radius: 6px; padding: 4px 10px; margin: 12px 0 2px;
}
.side-day-today { background: var(--accent); color: #fff; }
.side-week-form { margin: 6px 0 2px; }
.side-week-label { font-size: 13px; font-weight: 600; margin: 0; }
.side-week-form select { font-size: 13px; padding: 6px 8px; margin: 3px 0 0; }
.side-note { font-size: 12.5px; margin-bottom: 8px; }
.side-card { border-top: 1px solid var(--line); padding: 8px 0; }
.side-card-name { font-weight: 600; font-size: 14px; line-height: 1.4; }
.side-card-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.side-card-row .pill { font-size: 11.5px; padding: 0 8px; }
.side-link { text-decoration: none; }
@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-side { position: static; max-height: none; }
}
.btn-cancel { color: var(--bad); border-color: var(--bad); font-size: 15px; padding: 10px 14px; }

/* ฟอร์มความคิดเห็นผู้ตรวจทาน — เลือกผลด้วย radio + ช่องความคิดเห็น */
.review-choice { margin-bottom: 10px; }
.radio-line { display: block; font-weight: 600; padding: 7px 10px; margin: 4px 0; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.radio-line:hover { background: var(--accent-soft); }
.radio-line input { margin-right: 6px; }
.radio-danger:hover { background: var(--bad-soft); }

/* การ์ดผู้ใต้บังคับบัญชา (กล่องขวาของผจก.เขต) */
a.side-person { display: block; text-decoration: none; color: inherit; }
a.side-person:hover { background: var(--accent-soft); }

/* หน้าข้อมูลผู้ใต้บังคับบัญชา — แถววันนี้ในตารางแผน */
.row-today td { background: var(--accent-soft); }

/* ---------- วันสำคัญ / เทศกาล / อีเว้นท์ ---------- */
.cal-event {
  font-size: 10.5px; line-height: 1.5; padding: 0 4px; margin-top: 1px;
  background: #FFF3D6; color: #7A5A00; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-has-event .cal-daynum { color: #B8860B; }
.event-day-box { background: #FFF9EC; border-color: #E8D9A8; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.event-card { margin-bottom: 10px; }
.event-now { border-color: var(--accent); border-width: 2px; }
.event-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.event-stores summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-top: 4px; }
.event-store-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.btn-danger-text { color: var(--bad); }

/* ฟอร์มเลือกสาขา/ผู้รับแบบ checkbox หลายรายการ */
.prov-group { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.prov-head { font-size: 14px; display: block; margin-bottom: 4px; }
.store-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 10px; }
.store-check { display: block; font-size: 13px; font-weight: 400; margin: 0; padding: 2px 0; }

/* ตัวเลือกสาขาของอีเว้นท์ — การ์ดรายจังหวัด > กลุ่มรายอำเภอ > ชิปรายสาขา */
.prov-card { border: 1px solid var(--line); border-radius: 12px; margin: 12px 0; overflow: hidden; background: var(--surface); }
.prov-bar {
  display: flex; align-items: center; gap: 10px; background: var(--accent); color: #fff;
  padding: 9px 14px; margin: 0; cursor: pointer; user-select: none;
}
.prov-bar input { accent-color: #fff; width: 16px; height: 16px; }
.prov-name { font-weight: 800; font-size: 15.5px; flex: 1; }
.prov-count { font-size: 12.5px; font-weight: 700; background: rgba(255, 255, 255, .22); border-radius: 999px; padding: 2px 12px; white-space: nowrap; }
.dist-group { padding: 8px 14px 10px; border-top: 1px dashed var(--line); }
.dist-head {
  display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 700;
  color: var(--accent-dark); margin: 0 0 7px; cursor: pointer; user-select: none;
}
.dist-head input { accent-color: var(--accent); }
.dist-count { font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--accent-soft); border-radius: 999px; padding: 1px 9px; }
.store-chip-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.store-chip {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 11px 3px 8px; font-size: 12.5px; font-weight: 500; margin: 0; cursor: pointer;
  background: var(--surface); transition: border-color .1s, background .1s; user-select: none;
}
.store-chip:hover { border-color: var(--accent); }
.store-chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 700; }
.store-chip input { margin: 0; accent-color: var(--accent); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row label { flex: 1; min-width: 180px; }

/* ---------- ข่าวสาร ---------- */
.news-item {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin: 8px 0; text-decoration: none; color: var(--ink);
}
.news-item:hover { background: var(--accent-soft); }
.news-unread { border-left: 4px solid var(--accent); }
.news-unread .news-title { font-weight: 700; }
.news-title { font-weight: 600; }
.news-snippet { font-size: 13px; margin-top: 2px; }
.news-readbar { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 4px; }
.news-body p { margin: 0 0 8px; }
.news-body p:last-child { margin-bottom: 0; }

/* หน้าข้อมูลส่วนตัว + ลิงก์ชื่อผู้ใช้บนแถบเมนู */
a.uname { color: inherit; text-decoration: none; border-bottom: 1px dashed rgba(255, 255, 255, .5); }
a.uname:hover { border-bottom-style: solid; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.meta-line { margin: 6px 0 14px; line-height: 1.9; }
.meta-line form.inline { display: inline; }

/* ---------- เสียงลูกค้า (Customer Feedback) ---------- */
.fb-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.fb-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.fb-filters input, .fb-filters select { width: auto; font-size: 13.5px; padding: 7px 10px; }
.fb-item {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin: 8px 0; text-decoration: none; color: var(--ink);
}
.fb-item:hover { background: var(--accent-soft); }
.fb-open { border-left: 4px solid var(--bad); border-radius: 0 10px 10px 0; }
.fb-good { border-left: 4px solid var(--accent); border-radius: 0 10px 10px 0; }
.fb-item-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.fb-item-title { font-weight: 600; font-size: 14.5px; }
.fb-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.fb-item-sub { font-size: 13px; margin-top: 2px; }

/* Audit Short — แถวสถานะ ปกติ/ควรแก้ไข */
.audit-status { margin-top: 8px; }
.audit-status .radio-opt { font-size: 13.5px; padding: 5px 10px; }

/* หน้าเช็คอินเข้าสาขา — กล้องเซลฟี่ + คำใบ้ชวนยิ้ม */
.selfie-box { text-align: center; margin: 16px 0; }
.selfie-hint { font-size: 21px; font-weight: 800; color: var(--accent-dark); margin-bottom: 10px; }
.selfie-video {
  width: 100%; max-width: 400px; border-radius: 16px; border: 3px solid var(--accent);
  background: #111; transform: scaleX(-1); /* กลับซ้ายขวาแบบกระจก ให้เหมือนกล้องหน้ามือถือ */
}
.selfie-actions { justify-content: center; margin-top: 10px; }
.btn-checkin-go { width: 100%; font-size: 17px; padding: 13px; margin-top: 6px; }

.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 20px 10px 96px; }
.footer-trademark { margin-top: 4px; font-size: 11.5px; opacity: 0.85; }

/* ยอดขายรายวัน + ตัดจ่าย/Mark Down (ผจก.ร้าน SM) */
.sm-daygrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin: 12px 0; }
.sm-day {
  display: block; text-align: center; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 4px; background: var(--surface); text-decoration: none; color: var(--ink);
}
.sm-daynum { font-size: 17px; font-weight: 700; }
.sm-day-status { font-size: 13px; letter-spacing: 2px; margin-top: 2px; }
.sm-day-done { border-color: #7CB342; background: #F1F8E9; }
.sm-day-partial { border-color: #FFB74D; background: #FFF8E1; }
.sm-day-missing { border-color: #EF9A9A; background: #FFF5F5; }
.sm-day-future { opacity: .45; }
.sm-day-today { outline: 3px solid var(--accent); outline-offset: 1px; }

.sd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 14px; }
.sd-field { display: block; font-size: 14px; }
.sd-field input { width: 100%; margin-top: 3px; }
.sd-ro { padding: 7px 2px; border-bottom: 1px dashed var(--line); font-weight: 600; }
.sd-computed { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.sd-group { border: 1px solid var(--line); border-radius: 10px; margin: 10px 0; background: var(--surface); }
.sd-group summary {
  cursor: pointer; padding: 9px 12px; font-weight: 700; display: flex; justify-content: space-between; gap: 10px;
  list-style: none;
}
.sd-group summary::-webkit-details-marker { display: none; }
.sd-group summary::after { content: '▾'; color: var(--muted); }
.sd-group[open] summary { border-bottom: 1px solid var(--line); }
.sd-group[open] summary::after { content: '▴'; }
.sd-group .sd-grid { padding: 10px 12px 12px; }

.pct-up { color: #1B6E4B; font-weight: 700; }
.pct-down { color: #C62828; font-weight: 700; }
.row-total td { background: #EFF6F1; border-top: 2px solid var(--accent); font-weight: 600; }
.row-avg td { background: #F7FAF8; color: var(--muted); }
.row-grand td { background: var(--accent-soft); border-top: 3px double var(--accent-dark); font-weight: 700; }
.row-today td { background: #FFFDE7; }
.sales-table { font-size: 13px; white-space: nowrap; }
.sales-table th { position: sticky; top: 0; background: var(--surface); }
.row-review td { background: #FBFDFB; font-size: 13px; border-bottom: 2px solid var(--line); }
.review-inline { display: inline-flex; gap: 6px; margin-left: 12px; vertical-align: middle; }
.review-inline input { width: 240px; padding: 4px 8px; font-size: 13px; }

/* ตารางยอดขายรายวัน — แยกรอบ 7 วันเป็นบล็อกของตัวเอง มีหัวรอบ + ช่องว่างคั่น
   สีพาสเทลประจำรอบ (อ่อนๆ ไม่เด่นเกิน): มิ้นต์ → ฟ้า → ลาเวนเดอร์ → พีช → ชมพู · สรุปเดือน = ครีมทอง */
.week-block { margin: 22px 0; --wb-bg: var(--accent-soft); --wb-border: #A5D6A7; --wb-ink: var(--accent-dark); --wb-tint: #F4FAF5; }
.week-c0 { --wb-bg: #E6F4EA; --wb-border: #A8D5B3; --wb-ink: #2F6B43; --wb-tint: #F3FAF5; } /* มิ้นต์ */
.week-c1 { --wb-bg: #E7F1FB; --wb-border: #A9C9EC; --wb-ink: #2F5D8F; --wb-tint: #F3F8FD; } /* ฟ้า */
.week-c2 { --wb-bg: #F0EBFA; --wb-border: #C4B5E4; --wb-ink: #5D4A8A; --wb-tint: #F8F5FD; } /* ลาเวนเดอร์ */
.week-c3 { --wb-bg: #FBF0E3; --wb-border: #EBC69C; --wb-ink: #8F6430; --wb-tint: #FDF8F1; } /* พีช */
.week-c4 { --wb-bg: #FAEAEF; --wb-border: #E8AFC2; --wb-ink: #94465F; --wb-tint: #FDF4F7; } /* ชมพู */
.week-block-month { --wb-bg: #FAF3DC; --wb-border: #E0C97F; --wb-ink: #7D6420; --wb-tint: #FDF9EC; }
.week-block-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--wb-bg); border: 1px solid var(--wb-border); border-bottom: none;
  border-radius: 10px 10px 0 0; padding: 8px 14px;
}
.week-block-title { font-weight: 800; color: var(--wb-ink); }
.week-block-status { font-size: 13.5px; font-weight: 600; color: var(--wb-ink); }
.week-block .week-block-table { margin: 0; border-radius: 0 0 10px 10px; border-color: var(--wb-border); }
.week-block .sales-table th { background: var(--wb-tint); color: var(--wb-ink); }
.week-block .row-total td { background: var(--wb-bg); border-top: 2px solid var(--wb-border); }
.week-block .row-avg td { background: var(--wb-tint); }
.week-block .row-review td { background: var(--wb-tint); border-bottom: none; }
.week-block-month .row-total td { font-size: 15px; }

/* สรุปงานรายสัปดาห์ FC */
.sum-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.sum-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #FAFCFA; text-align: center; }
.sum-num { font-size: 26px; font-weight: 800; }
.sum-label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.sum-score { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 15px; }
.sum-lines { margin: 6px 0 0 18px; } .sum-lines li { margin: 4px 0; }

/* วิเคราะห์ยอดขาย */
.an-tabs { display: flex; gap: 0; margin: 14px 0 16px; border-bottom: 2px solid var(--line); }
.an-tab { appearance: none; background: none; border: none; border-bottom: 3px solid transparent; margin-bottom: -2px;
  padding: 9px 18px; font: inherit; font-size: 15.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.an-tab:hover { color: var(--accent-dark); }
.an-tab-on { color: var(--accent-dark); border-bottom-color: var(--accent); }
.store-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 4px; }
.store-tab { display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 13.5px; text-decoration: none; color: var(--ink); }
.store-tab:hover { border-color: var(--accent); }
.store-tab-on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.flag-line { padding: 4px 0; }
.flag-scroll { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px 12px; background: #FDFCFA; }
.share-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.share-label { width: 190px; flex-shrink: 0; font-size: 14px; }
.share-bar { flex: 1; height: 16px; background: #EFF3EF; border-radius: 8px; overflow: hidden; }
.share-fill { height: 100%; background: linear-gradient(90deg, #7CB98F, #1B6E4B); border-radius: 8px; }
.share-val { width: 170px; flex-shrink: 0; text-align: right; font-size: 13.5px; }

/* สรุปตัดจ่าย+MD: ช่องสาขากว้างอ่านง่าย ตัวเลขกระชับ + เว้นช่องว่างระหว่างกลุ่ม FC */
.wo-table th, .wo-table td { padding: 7px 7px; }
.wo-table th:first-child, .wo-table td:first-child { min-width: 250px; padding-left: 12px; }
.wo-table td.num, .wo-table th.num { font-size: 13.5px; white-space: nowrap; }
.wo-gap td { background: var(--bg); height: 16px; padding: 0; border-bottom: 1px solid var(--line); }
.wo-head td { background: var(--wb-bg); color: var(--wb-ink); font-weight: 800; font-size: 14px; border-top: 1px solid var(--wb-border); border-bottom: 1px solid var(--wb-border); }
.wo-row td { background: var(--wb-tint); }
.wo-row td a { color: var(--wb-ink); }
.wo-sum td { background: var(--wb-bg); border-top: 2px solid var(--wb-border); color: var(--wb-ink); }

/* เปลี่ยนแผนกระทันหัน */
.plan-change { margin: -6px 0 10px; font-size: 14px; }
.plan-change summary { cursor: pointer; color: var(--accent-dark); }
.plan-change-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.plan-change-form select { max-width: 280px; }
.plan-change-form input { flex: 1; min-width: 220px; }

/* แบรนด์ SOMA — ตัว O เป็นโลโก้วงกลม+เส้นชีพจร (ผู้ใช้กำหนดชื่อระบบ 2026-09-02) */
.brand-soma { display: inline-flex; align-items: center; gap: 1px; font-weight: 800; letter-spacing: 1px; }
.soma-o { width: 24px; height: 24px; vertical-align: middle; margin: 0 1px; }
.login-soma { display: inline-flex; align-items: center; gap: 2px; color: #2D5F49; font-weight: 800; letter-spacing: 3px; }
.soma-o-lg { width: 46px; height: 46px; margin: 0 2px; }

/* รายงานเช็คอิน HR แบบหน้าเดียว (แบบ B — ผู้ใช้เลือกจาก mockup 2026-09-02):
   ช่องสีจิ๋ว + เวลาเข้าตัวเล็กในช่อง 31 วันพอดีจอโน้ตบุ๊ก ไม่ต้องเลื่อนซ้ายขวา */
.hrc-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 12px 0; overflow-x: auto; }
.hrc-table { border-collapse: collapse; width: 100%; }
.hrc-table th, .hrc-table td { padding: 3px 4px; border-bottom: 1px solid #EDF1EC; text-align: left; white-space: nowrap; }
.hrc-table th { font-size: 11.5px; color: var(--muted); }
.hrc-table td.num, .hrc-table th.num { text-align: right; font-size: 12.5px; }
.hrc-name { font-size: 13px; max-width: 185px; overflow: hidden; text-overflow: ellipsis; }
.hrc-name a { text-decoration: none; }
.hrc-role { font-size: 11px; color: var(--muted); }
.hrc-days { display: flex; gap: 2px; }
.hrc-daynums span { width: 27px; font-size: 9.5px; color: var(--muted); text-align: center; display: inline-block; }
.hrc-cell {
  width: 27px; height: 24px; border-radius: 3px; font-size: 8.8px; text-align: center;
  display: flex; flex-direction: column; justify-content: center; line-height: 1.15;
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.hrc-ok { background: #8FCB9B; }
.hrc-out { background: #F2C14E; }
/* ไม่มีการเช็คอิน = สีแดงชัด ๆ ให้สะดุดตา (ผู้ใช้กำหนด 2026-10-09) */
.hrc-miss { background: #D64545; }
.hrc-holiday { background: #BBD5F0; }                      /* วันหยุด */
.hrc-leave { background: #6E9BC9; color: #fff; }            /* วันลา — แยกสีจากวันหยุด */
.hrc-meet { background: #D8C6EE; }
.hrc-future { background: #F0F2F0; }
.hrc-today { outline: 2px solid var(--accent); outline-offset: -1px; }
/* ตัวสลับว่าช่องในตารางจะโชว์เวลาเช็คอิน หรือ รหัสสาขาที่เช็คอิน (ผู้ใช้ขอ 2026-10-09) */
.hrc-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.hrc-toggle a { padding: 6px 12px; font-size: 13px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.hrc-toggle a + a { border-left: 1px solid var(--line); }
.hrc-toggle a:hover { background: var(--accent-soft); }
.hrc-toggle a.on { background: var(--accent); color: #fff; font-weight: 700; }
.hrc-legend { display: flex; gap: 14px; margin: 10px 2px 2px; font-size: 12.5px; flex-wrap: wrap; align-items: center; }
.hrc-legend .hrc-cell { display: inline-flex; width: 18px; height: 16px; vertical-align: middle; }

/* เมนูมือถือ (ปุ่ม ☰) — จอเล็กเมนูยุบเป็นแผงกางลง แถบบนเหลือแถวเดียว (ผู้ใช้ขอ 2026-09-21) */
.nav-toggle { display: none; }
@media (max-width: 900px) {
  .topbar { flex-wrap: nowrap; position: sticky; }
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.35); color: #fff;
    border-radius: 8px; width: 42px; height: 38px; font-size: 20px; cursor: pointer; flex-shrink: 0;
  }
  .nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 0; background: var(--accent-dark);
    box-shadow: 0 8px 18px rgba(0,0,0,0.25); z-index: 60; padding: 4px 0 8px;
  }
  .topbar.nav-open .nav-links { display: flex; }
  .nav-links a { padding: 13px 22px; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,0.08); border-radius: 0; }
  .nav-links a:last-child { border-bottom: none; }
  .brand { flex: 1; }
  .uname { max-width: 96px; font-size: 13px; }
  .nav-user { gap: 6px; }
  .nav-user .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.4); padding: 6px 10px; }
}
