:root {
  --rs-navy: #0D47A1;
  --rs-navy-deep: #0A3A8A;
  --rs-blue: #1565C0;
  --rs-bg: #F0F4FA;
  --rs-surface: #fff;
  --rs-border: #e3eaf5;
  --rs-text: #222;
  --rs-muted: #666;
  --rs-ok: #2E7D32;
  --rs-warn: #EF6C00;
  --rs-danger: #C62828;
  --rs-sidebar-w: 280px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --mobile-menu-offset: 62px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* ปิด pull-to-refresh ของเบราว์เซอร์ — รีเฟรชใช้ปุ่ม Header เท่านั้น */
  overscroll-behavior-y: none;
}
body {
  font-family: "Sarabun", system-ui, sans-serif;
  background: var(--rs-bg);
  color: var(--rs-text);
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
}
body.menu-open { overflow: hidden; }
#app {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  min-height: 100%;
}

.view { display: none; min-height: 100%; }
.view.active { display: block; }

.logo-shine-wrap {
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.logo-shine-inner { width: 100%; height: 100%; display: flex; }
.logo-shine-inner svg { width: 100%; height: 100%; display: block; }

.login-hero {
  background: linear-gradient(160deg, var(--rs-navy), #0A3A8A 60%, var(--rs-blue));
  color: #fff;
  padding: 40px 24px 56px;
  text-align: center;
}
.login-logo { width: 88px; height: 88px; margin: 0 auto 16px; border-radius: 18px; padding: 10px; }
.login-hero .brand { font-size: 28px; font-weight: 700; letter-spacing: .5px; }
.login-hero p { margin: 8px 0 0; opacity: .9; }

.login-card { margin: -36px 16px 16px; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--rs-muted); }
.login-card input {
  border: 1px solid var(--rs-border); border-radius: 12px; padding: 14px;
  font-size: 16px; font-family: inherit;
}
.pin-field {
  position: relative;
  display: grid;
}
.pin-field input {
  padding-right: 48px;
  width: 100%;
  box-sizing: border-box;
}
.pin-eye {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: transparent; color: var(--rs-muted); cursor: pointer;
  display: grid; place-items: center; font-size: 16px;
}
.pin-eye:hover, .pin-eye[aria-pressed="true"] { color: var(--rs-navy); background: #eef3fb; }
.login-remember {
  display: flex !important; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 600; color: var(--rs-text);
  cursor: pointer; user-select: none;
}
.login-remember input {
  width: 18px; height: 18px; margin: 0; accent-color: var(--rs-navy);
  flex-shrink: 0;
}
.forgot-panel {
  display: grid; gap: 12px;
  margin-top: 2px; padding: 12px;
  border-radius: 12px; border: 1px dashed #90caf9;
  background: #F5FAFF;
}
.forgot-panel[hidden] { display: none !important; }
.forgot-panel-title {
  margin: 0; font-size: 13px; font-weight: 800; color: var(--rs-navy);
}
#btn-forgot-open .forgot-chevron {
  font-size: 11px; transition: transform .2s ease; opacity: .75;
}
#btn-forgot-open[aria-expanded="true"] .forgot-chevron {
  transform: rotate(180deg);
}

.install-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 0 16px 24px; width: calc(100% - 32px);
  border: 1px dashed #90caf9; border-radius: 12px; padding: 12px;
  background: #e3f2fd; color: var(--rs-navy); font: inherit; font-weight: 600; cursor: pointer;
}

.card {
  background: var(--rs-surface); border: 1px solid var(--rs-border);
  border-radius: 14px; padding: 16px;
  box-shadow: 0 4px 16px rgba(13, 71, 161, .06);
}

.btn {
  border: 0; border-radius: 12px; padding: 14px 18px;
  font-size: 16px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.btn-primary { background: var(--rs-blue); color: #fff; }
.btn-ok { background: var(--rs-ok); color: #fff; }
.btn-danger { background: var(--rs-danger); color: #fff; }
.btn-ghost { background: #eef3fb; color: var(--rs-navy); }
.btn-block { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.error { color: var(--rs-danger); font-size: 14px; margin: 8px 0 0; }
.muted { color: var(--rs-muted); font-size: 13px; }

.sidebar { display: none; }
.app-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }

#view-app {
  display: none; min-height: 100%;
  padding-bottom: calc(72px + var(--safe-bottom));
}
#view-app.active { display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--rs-blue); color: #fff;
}
.topbar-user {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  border: 0; background: transparent; color: inherit;
  text-align: left; font: inherit; cursor: pointer;
  padding: 2px 4px; border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
}
.topbar-user:active { background: rgba(255,255,255,.1); }
.topbar-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.22);
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px; flex-shrink: 0;
  overflow: hidden; border: 2px solid rgba(255,255,255,.35);
}
.topbar-avatar.has-photo img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title strong {
  display: block; font-size: 15px; font-weight: 800;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title span { font-size: 11px; opacity: .9; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.15); color: #fff; font-size: 16px;
  position: relative; flex-shrink: 0;
  display: grid; place-items: center;
  cursor: pointer;
}
.icon-btn:disabled { opacity: .7; cursor: wait; }
.icon-btn.is-spinning i {
  animation: ywy-spin .7s linear infinite;
}
@keyframes ywy-spin {
  to { transform: rotate(360deg); }
}
.notif-btn .notif-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: #E53935; color: #fff;
  font-size: 10px; font-weight: 800; line-height: 16px;
  display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--rs-blue);
}

/* Notification sheet */
.notif-sheet {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
}
.notif-sheet[hidden] { display: none !important; }
.notif-sheet-backdrop {
  position: absolute; inset: 0; background: rgba(10, 30, 60, .45);
}
.notif-sheet-panel {
  position: relative; z-index: 1;
  width: min(520px, 100%);
  max-height: min(72vh, 560px);
  background: #fff; color: var(--rs-text);
  border-radius: 20px 20px 0 0;
  padding: 14px 14px calc(14px + var(--safe-bottom));
  display: grid; gap: 10px;
  box-shadow: 0 -12px 40px rgba(0,0,0,.18);
  animation: notifSheetIn .22s ease;
}
@keyframes notifSheetIn {
  from { transform: translateY(24px); opacity: .6; }
  to { transform: none; opacity: 1; }
}
.notif-sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.notif-sheet-head strong { font-size: 15px; color: var(--rs-navy); }
.notif-sheet-head .icon-btn {
  background: #eef3fb; color: var(--rs-navy);
}
.notif-sheet-hint { margin: 0; font-size: 12px; }
.notif-list {
  overflow: auto; display: grid; gap: 8px;
  max-height: min(56vh, 420px); padding-bottom: 4px;
}
.notif-empty {
  text-align: center; padding: 28px 12px; font-size: 13px;
}
.notif-item {
  border: 1px solid var(--rs-border); border-radius: 14px;
  padding: 12px; background: #f8fafc; display: grid; gap: 6px;
}
.notif-item-top {
  display: flex; justify-content: space-between; gap: 8px; align-items: flex-start;
}
.notif-item strong { font-size: 13px; color: var(--rs-navy); }
.notif-item p { margin: 0; font-size: 12px; color: var(--rs-muted); line-height: 1.4; }
.notif-status {
  font-size: 11px; font-weight: 800; border-radius: 999px;
  padding: 3px 8px; white-space: nowrap;
}
.notif-status.pending { background: #FFF3E0; color: #EF6C00; }
.notif-status.approved { background: #E8F5E9; color: #2E7D32; }
.notif-status.rejected { background: #FFEBEE; color: #C62828; }
.notif-status.cancelled { background: #ECEFF1; color: #607D8B; }
.notif-meta { font-size: 11px; color: #90A4AE; }

.main {
  padding: 16px;
  flex: 1;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}
.screen { display: none; width: 100%; max-width: 100%; }
.screen.active { display: block; }

.flood-help-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 12px;
  padding: 14px 16px;
  border-radius: 14px;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: 18px;
  background: #dc2626;
  box-shadow: 0 8px 18px rgba(220, 38, 38, 0.35);
  animation: flood-help-blink 1s ease-in-out infinite;
}
.flood-help-btn:active { transform: scale(0.98); }
@keyframes flood-help-blink {
  0%, 100% {
    background: #dc2626;
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45);
  }
  50% {
    background: #f97316;
    box-shadow: 0 0 0 8px rgba(249, 115, 22, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .flood-help-btn { animation: none; background: #dc2626; }
}
.home-dash { display: grid; gap: 14px; width: 100%; max-width: 100%; min-width: 0; }

/* Home hero: รูปสไลด์ + สรุปงาน ในส่วนเดียว */
.home-hero-combo {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
  background: #0A3A8A;
  box-shadow: 0 12px 32px rgba(13, 71, 161, .2);
}
.home-hero-slider {
  position: relative;
  border-radius: 0;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
  background: #0A3A8A;
  box-shadow: none;
  aspect-ratio: 16 / 11;
  min-height: 220px;
}
.home-hero-track { position: absolute; inset: 0; }
.home-hero-slide {
  position: absolute; inset: 0; margin: 0;
  opacity: 0; transform: scale(1.04);
  transition: opacity .7s ease, transform 6s ease;
  pointer-events: none;
}
.home-hero-slide.is-active {
  opacity: 1; transform: scale(1);
  pointer-events: auto; z-index: 1;
}
.home-hero-slide img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 35%;
  display: block;
}
.home-hero-slide::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,28,68,.15) 0%, rgba(8,28,68,.25) 45%, rgba(8,28,68,.55) 100%);
}
.home-hero-dots {
  position: absolute; left: 0; right: 0; top: 10px; z-index: 3;
  display: flex; justify-content: center; gap: 6px;
  pointer-events: auto;
}
.home-hero-dot {
  width: 7px; height: 7px; border-radius: 999px; border: 0;
  background: rgba(255,255,255,.5); padding: 0; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: width .2s ease, background .2s ease;
}
.home-hero-dot.is-active {
  width: 18px; background: #fff;
}
.home-hero-progress {
  position: relative;
  z-index: 4;
  margin: -72px 10px 10px;
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(8, 28, 68, .28);
  border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(2px);
}
.home-block {
  min-width: 0; max-width: 100%;
  border-radius: 18px; padding: 14px;
  border: 1px solid transparent;
  box-shadow: 0 8px 22px rgba(15, 40, 80, .06);
}
.block-label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 800; letter-spacing: .02em;
}
.block-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px;
}
.block-chip {
  background: rgba(255,255,255,.7); border-radius: 999px; padding: 4px 10px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.block-hint { margin: 0 0 12px; font-size: 12px; opacity: .78; font-weight: 600; }

/* A: Progress */
.block-progress {
  background: linear-gradient(145deg, #0D47A1, #1565C0 55%, #1E88E5);
  color: #fff;
}
.block-progress .block-label { color: #fff; margin-bottom: 12px; }
.progress-hero {
  display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: center;
}
.progress-ring-wrap { position: relative; width: 110px; height: 110px; }
.progress-ring { width: 110px; height: 110px; transform: rotate(-90deg); }
.progress-ring-bg { fill: none; stroke: rgba(255,255,255,.22); stroke-width: 10; }
.progress-ring-fg {
  fill: none; stroke: #A5D6A7; stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 327; stroke-dashoffset: 327;
  transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1);
  filter: drop-shadow(0 0 6px rgba(165,214,167,.5));
}
.progress-ring-center {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  transform: rotate(0deg);
}
.progress-ring-center strong { font-size: 22px; line-height: 1; }
.progress-ring-center small { font-size: 10px; opacity: .85; font-weight: 700; }
.block-progress .summary-grid { margin: 0; gap: 8px; }
.block-progress .stat {
  color: #fff; backdrop-filter: blur(4px);
  position: relative;
}
.block-progress .stat span:not(.stat-ico) { color: #fff; font-size: 22px; }
.block-progress .stat small { color: rgba(255,255,255,.92); }
button.stat {
  font: inherit; width: 100%; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.stat-jump {
  transition: transform .15s ease, filter .15s ease, box-shadow .15s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.stat-jump::after {
  content: "";
  position: absolute; right: 6px; bottom: 6px;
  width: 14px; height: 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.28) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z'/%3E%3C/svg%3E") center / 10px no-repeat;
  opacity: .9;
  pointer-events: none;
}
.stat-jump:hover { filter: brightness(1.06); }
.stat-jump:active {
  transform: scale(.96);
  filter: brightness(.96);
}
.stat-jump:focus-visible {
  outline: 2px solid #fff; outline-offset: 2px;
}
/* สีแยกตามประเภท — ดูกดได้ชัด */
.block-progress .stat.tone-blue {
  background: linear-gradient(160deg, rgba(33,150,243,.55), rgba(13,71,161,.42));
  border: 1px solid rgba(144,202,249,.65);
}
.block-progress .stat.tone-blue .stat-ico { background: rgba(33,150,243,.85); }
.block-progress .stat.tone-green {
  background: linear-gradient(160deg, rgba(67,160,71,.58), rgba(27,94,32,.4));
  border: 1px solid rgba(165,214,167,.7);
}
.block-progress .stat.tone-green .stat-ico { background: rgba(46,125,50,.9); }
.block-progress .stat.tone-orange {
  background: linear-gradient(160deg, rgba(255,152,0,.58), rgba(230,81,0,.4));
  border: 1px solid rgba(255,204,128,.7);
}
.block-progress .stat.tone-orange .stat-ico { background: rgba(239,108,0,.9); }
.block-work.is-jump-flash {
  box-shadow: 0 0 0 3px rgba(46, 125, 50, .35), 0 8px 22px rgba(15, 40, 80, .06);
  transition: box-shadow .35s ease;
}
.home-store.is-jump-hit {
  outline: 2px solid #1565C0;
  outline-offset: 1px;
  box-shadow: 0 0 0 4px rgba(21,101,192,.2);
  transition: box-shadow .3s ease, outline-color .3s ease;
}
.home-store.is-done.is-jump-hit {
  outline-color: #2E7D32;
  box-shadow: 0 0 0 4px rgba(46,125,50,.22);
}
.home-store.is-pending.is-jump-hit,
.home-store.is-in.is-jump-hit {
  outline-color: #EF6C00;
  box-shadow: 0 0 0 4px rgba(239,108,0,.22);
}
.stat-ico {
  display: grid; place-items: center; width: 26px; height: 26px; margin: 0 auto 4px;
  border-radius: 8px; background: rgba(255,255,255,.18); font-size: 12px;
}
.progress-bar-track {
  margin-top: 12px; height: 8px; border-radius: 999px; background: rgba(255,255,255,.2); overflow: hidden;
}
.progress-bar-track i {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, #A5D6A7, #FFF59D);
  transition: width .8s cubic-bezier(.2,.8,.2,1);
  width: calc(var(--p, 0) * 1%);
}

/* B: Work / check-in */
.block-work {
  background: linear-gradient(180deg, #E8F5E9, #F1F8E9 30%, #fff 70%);
  border-color: #A5D6A7;
}
.block-work .block-label { color: #1B5E20; }
.block-work .block-chip { background: #C8E6C9; color: #1B5E20; }
.block-work .block-hint { color: #2E7D32; }

/* C: Week */
.block-week {
  background: linear-gradient(180deg, #EDE7F6, #F3E5F5 28%, #fff 65%);
  border-color: #CE93D8;
}
.block-week .block-label,
.block-week .home-fold-title { color: #6A1B9A; }
.block-week .block-chip { background: #E1BEE7; color: #6A1B9A; }
.block-week .chip-off { background: #FFECB3; color: #E65100; }
.block-week .block-hint { color: #7B1FA2; }
.block-week-manage {
  background: linear-gradient(160deg, #EDE7F6, #F3E5F5 50%, #fff);
  border-color: #B39DDB;
}
.block-week-manage .home-fold-title { color: #5E35B1; }

.home-fold { padding: 0; overflow: hidden; }
.home-fold-summary {
  list-style: none;
  display: flex; align-items: center; gap: 8px;
  padding: 14px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.home-fold-summary::-webkit-details-marker { display: none; }
.home-fold-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 800; letter-spacing: .02em;
  flex: 1; min-width: 0;
}
.home-fold-chevron {
  color: #7E57C2; font-size: 12px;
  transition: transform .2s ease;
  flex-shrink: 0;
}
.home-fold[open] > .home-fold-summary .home-fold-chevron {
  transform: rotate(180deg);
}
.home-fold-body {
  padding: 0 14px 14px;
}
.home-fold .block-chip { margin-left: auto; }

/* D: Rules */
.block-rules {
  background: #fff; border-color: var(--rs-border);
  box-shadow: none;
}
.block-rules summary {
  color: var(--rs-navy); display: flex; gap: 8px; align-items: center;
}

.summary-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.stat {
  background: #fff; border-radius: 14px; padding: 12px 6px; text-align: center;
  border: 1px solid var(--rs-border);
}
.stat span:not(.stat-ico) { display: block; font-size: 28px; font-weight: 700; color: var(--rs-navy); }
.stat.ok span, .stat-green span:not(.stat-ico) { color: var(--rs-ok); }
.stat.warn span, .stat-orange span:not(.stat-ico) { color: var(--rs-warn); }
.stat-blue span:not(.stat-ico) { color: #1565C0; }
.stat small { color: var(--rs-muted); font-size: 11px; font-weight: 700; }

.banner {
  background: #FFF3E0; color: #E65100; border-radius: 12px;
  padding: 12px 14px; font-weight: 600;
}
.dayoff-banner {
  display: flex; gap: 12px; align-items: center;
  border: 1px solid #FFCC80;
}
.dayoff-banner[hidden] { display: none !important; }
.dayoff-banner i { font-size: 22px; }
.dayoff-banner strong { display: block; }
.dayoff-banner span { font-weight: 500; font-size: 13px; opacity: .9; }

.home-section { display: grid; gap: 10px; }
.section-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.section-head h2 {
  margin: 0; font-size: 15px; color: var(--rs-navy);
  display: flex; gap: 8px; align-items: center;
}
.home-store-list { display: grid; gap: 8px; }
.home-store-filter {
  display: grid; gap: 8px; margin: 0 0 12px;
  padding: 10px 12px; border-radius: 14px;
  background: #fff; border: 1px solid #c8e6c9;
  box-shadow: 0 2px 10px rgba(46,125,50,.05);
}
.home-store-filter[hidden] { display: none !important; }
.hsf-row { display: grid; gap: 8px; }
.hsf-row-2 { grid-template-columns: 1fr 1fr; }
.hsf-search {
  display: flex; align-items: center; gap: 8px;
  background: #f4faf5; border: 1px solid #c8e6c9; border-radius: 12px;
  padding: 0 12px; min-height: 42px;
}
.hsf-search i { color: #2E7D32; opacity: .75; }
.hsf-search input {
  flex: 1; border: 0; background: transparent; outline: none;
  font: inherit; font-size: 14px; color: var(--rs-navy); min-width: 0;
}
.home-store-filter select {
  width: 100%; min-height: 40px; border-radius: 12px;
  border: 1px solid #c8e6c9; background: #f4faf5; color: var(--rs-navy);
  padding: 0 10px; font: inherit; font-size: 13px; font-weight: 600;
}
.hsf-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; font-weight: 700; color: #2E7D32;
}
.hsf-meta .btn { padding: 4px 10px; font-size: 12px; }
.home-store {
  background: #fff; border: 1px solid #c8e6c9; border-radius: 14px;
  padding: 0; display: grid; gap: 0;
  box-shadow: 0 4px 14px rgba(46,125,50,.06);
  overflow: hidden;
}
.home-store.is-done { border-color: #66BB6A; background: linear-gradient(180deg, #fff, #E8F5E9); }
.home-store.is-in { border-color: #42A5F5; background: linear-gradient(180deg, #fff, #E3F2FD); }
.home-store.is-pending { border-color: #FFB74D; border-left: 5px solid #EF6C00; }
.home-store-summary {
  width: 100%; border: 0; background: transparent; font: inherit; text-align: left;
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 10px 12px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.home-store-summary-main { min-width: 0; flex: 1; display: grid; gap: 2px; }
.home-store-summary-main strong {
  color: var(--rs-navy); font-size: 14px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.home-store-summary-side {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.home-store-chevron {
  color: #78909C; font-size: 12px; transition: transform .2s ease;
}
.home-store-acc.is-open .home-store-chevron { transform: rotate(180deg); }
.home-store-body {
  display: grid; gap: 10px; padding: 10px 12px 12px;
  border-top: 1px solid rgba(0,0,0,.06);
}
.home-store-body[hidden] { display: none !important; }
.home-store-top {
  display: flex; justify-content: space-between; gap: 10px; align-items: flex-start;
}
.home-store-top strong { color: var(--rs-navy); font-size: 15px; }
.home-store-meta { color: var(--rs-muted); font-size: 11px; margin-top: 0; line-height: 1.35; }
.home-store-times {
  display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; font-weight: 700;
}
.time-pill {
  background: #eef3fb; color: var(--rs-navy); border-radius: 999px; padding: 4px 10px;
}
.time-pill.ok { background: #E8F5E9; color: #2E7D32; }
.time-pill.warn { background: #FFF3E0; color: #EF6C00; }
.home-store-photos {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.punch-photo {
  display: grid; gap: 4px; justify-items: center;
  border: 1px solid var(--rs-border); border-radius: 12px; padding: 4px;
  background: #fff; cursor: pointer; font: inherit; color: var(--rs-muted);
  width: 72px; -webkit-tap-highlight-color: transparent;
}
.punch-photo img {
  width: 64px; height: 64px; object-fit: cover; border-radius: 8px; display: block;
  background: #eef3fb;
}
.punch-photo span { font-size: 11px; font-weight: 700; }
.punch-photo:active { transform: scale(.97); }
.photo-viewer {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.photo-viewer[hidden] { display: none !important; }
.photo-viewer-backdrop {
  position: absolute; inset: 0; background: rgba(8, 20, 40, .72);
}
.photo-viewer-panel {
  position: relative; z-index: 1; width: min(420px, 100%);
  background: #0f172a; border-radius: 16px; overflow: hidden;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
}
.photo-viewer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; color: #fff;
}
.photo-viewer-head .icon-btn { background: rgba(255,255,255,.12); }
.photo-viewer-panel img {
  display: block; width: 100%; max-height: min(70vh, 520px); object-fit: contain; background: #000;
}
.home-store-actions { display: flex; gap: 8px; }
.home-store-actions .btn { flex: 1; }

.week-plan-host {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  gap: 0;
}

/* —— Supervisor monthly calendar —— */
.sup-cal { display: grid; gap: 10px; }
.sup-cal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: linear-gradient(90deg, #0D47A1, #1565C0 55%, #455A64);
  color: #fff; border-radius: 14px; padding: 8px 10px;
}
.sup-cal-head .btn-icon {
  width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center;
}
.sup-cal-title { text-align: center; flex: 1; min-width: 0; }
.sup-cal-title strong { display: block; font-size: 16px; }
.sup-cal-title small { opacity: .85; font-size: 12px; }
.sup-cal-dow {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px;
  text-align: center; font-size: 11px; font-weight: 700; color: #455A64;
}
.sup-cal-dow .is-sun { color: #C62828; }
.sup-cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px;
}
.sup-cal-cell {
  position: relative; min-height: 64px; border: 1px solid #CFD8DC; border-radius: 10px;
  background: #fff; padding: 4px; text-align: left; font: inherit; cursor: pointer;
  display: grid; align-content: start; gap: 2px;
}
.sup-cal-cell.is-empty { border: 0; background: transparent; pointer-events: none; }
.sup-cal-cell.is-sun .sup-cal-num { color: #C62828; }
.sup-cal-cell.is-today { outline: 2px solid #1565C0; outline-offset: -1px; background: #E3F2FD; }
.sup-cal-cell.is-picked { box-shadow: 0 0 0 2px #6A1B9A inset; }
.sup-cal-cell.has-plan { border-color: #90CAF9; background: linear-gradient(180deg, #E3F2FD, #fff); }
.sup-cal-cell.has-done { border-color: #81C784; background: linear-gradient(180deg, #E8F5E9, #fff); }
.sup-cal-num { font-size: 12px; font-weight: 800; color: #263238; justify-self: end; }
.sup-cal-badge {
  justify-self: start; font-size: 10px; font-weight: 800; color: #0D47A1;
  background: #BBDEFB; border-radius: 999px; padding: 1px 6px;
}
.sup-cal-cell.has-done .sup-cal-badge { color: #1B5E20; background: #C8E6C9; }
.sup-cal-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #43A047;
  justify-self: start;
}
.sup-cal-names {
  font-size: 9px; line-height: 1.25; color: #546E7A; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.sup-cal-detail-card {
  background: #fff; border: 1px solid #CE93D8; border-radius: 14px; padding: 12px;
  display: grid; gap: 8px;
}
.sup-cal-detail-card h3 { margin: 0; font-size: 14px; color: #4A148C; }
.sup-cal-store {
  display: flex; justify-content: space-between; gap: 8px; align-items: flex-start;
  padding: 8px 10px; border-radius: 10px; background: #F3E5F5; font-size: 13px;
}
.sup-cal-store.ok { background: #E8F5E9; }
.sup-cal-store.in { background: #E3F2FD; }
.sup-cal-store .t { font-size: 11px; font-weight: 700; color: #5E35B1; white-space: nowrap; }
.sup-cal-store.ok .t { color: #2E7D32; }
.sup-cal-store.in .t { color: #1565C0; }

.sup-day-sheet {
  position: fixed; inset: 0; z-index: 80; display: grid; align-items: end;
}
.sup-day-sheet[hidden] { display: none !important; }
.sup-day-sheet-backdrop { position: absolute; inset: 0; background: rgba(10,22,40,.45); }
.sup-day-sheet-panel {
  position: relative; z-index: 1; background: #fff;
  border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  max-height: min(88vh, 720px); display: grid; grid-template-rows: auto auto auto 1fr auto; gap: 8px;
  box-shadow: 0 -8px 28px rgba(0,0,0,.18);
}
.sup-day-sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sup-day-sheet-head strong { font-size: 15px; color: var(--rs-navy); }
.sup-day-picks {
  overflow: auto; display: grid; gap: 6px; min-height: 120px;
  -webkit-overflow-scrolling: touch;
}
.sup-day-pick {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid #CFD8DC; border-radius: 12px; background: #FAFAFA; cursor: pointer;
}
.sup-day-pick.on { border-color: #1565C0; background: #E3F2FD; }
.sup-day-pick input { margin-top: 3px; }
.sup-day-pick span { display: grid; gap: 2px; font-size: 13px; color: #263238; }
.sup-day-pick small { color: #78909C; font-size: 11px; }
.sup-day-sheet-foot {
  display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px;
}
.sup-day-sheet-foot[hidden],
.sup-pick-filters[hidden],
#sup-day-search-wrap[hidden],
#sup-day-store-picks[hidden] { display: none !important; }
.sup-pick-count {
  font-size: 12px; font-weight: 600; padding: 2px 2px 6px;
}
body.sup-day-open { overflow: hidden; }

.week-plan {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px;
  width: 100%; max-width: 100%; min-width: 0;
}
.week-plan-scroll {
  width: 100%; max-width: 100%; min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.week-day {
  background: #fff; border: 1px solid #CE93D8; border-radius: 12px;
  padding: 8px 6px; min-height: 88px; display: grid; gap: 4px; align-content: start;
  cursor: pointer; font: inherit; text-align: left; width: 100%;
  border-top-width: 4px;
  min-width: 0;
}
/* สีวันแบบไทย */
.week-day.day-Sun {
  border-top-color: #E53935; background: linear-gradient(180deg, #FFEBEE, #fff);
}
.week-day.day-Sun .week-day-name,
.week-day.day-Sun .week-day-count { color: #C62828; }
.week-day.day-Mon {
  border-top-color: #F9A825; background: linear-gradient(180deg, #FFFDE7, #fff);
}
.week-day.day-Mon .week-day-name,
.week-day.day-Mon .week-day-count { color: #F57F17; }
.week-day.day-Tue {
  border-top-color: #EC407A; background: linear-gradient(180deg, #FCE4EC, #fff);
}
.week-day.day-Tue .week-day-name,
.week-day.day-Tue .week-day-count { color: #AD1457; }
.week-day.day-Wed {
  border-top-color: #43A047; background: linear-gradient(180deg, #E8F5E9, #fff);
}
.week-day.day-Wed .week-day-name,
.week-day.day-Wed .week-day-count { color: #2E7D32; }
.week-day.day-Thu {
  border-top-color: #FB8C00; background: linear-gradient(180deg, #FFF3E0, #fff);
}
.week-day.day-Thu .week-day-name,
.week-day.day-Thu .week-day-count { color: #EF6C00; }
.week-day.day-Fri {
  border-top-color: #1E88E5; background: linear-gradient(180deg, #E3F2FD, #fff);
}
.week-day.day-Fri .week-day-name,
.week-day.day-Fri .week-day-count { color: #1565C0; }
.week-day.day-Sat {
  border-top-color: #8E24AA; background: linear-gradient(180deg, #F3E5F5, #fff);
}
.week-day.day-Sat .week-day-name,
.week-day.day-Sat .week-day-count { color: #6A1B9A; }

.week-day.is-today {
  box-shadow: 0 0 0 2px rgba(13,71,161,.18);
  transform: translateY(-1px);
}
.week-day.is-off {
  background: #ECEFF1 !important;
  border-style: dashed;
  border-top-style: solid;
  filter: grayscale(.35);
  opacity: .92;
}
.week-day.is-off .week-day-count { color: #90A4AE !important; }
.week-day.is-off .week-day-name { color: #78909C !important; }
.week-day.picked { outline: 2px solid #455A64; outline-offset: 1px; }
@media (max-width: 700px) {
  .week-plan-scroll {
    display: block;
  }
  .week-plan {
    display: flex;
    width: max-content;
    max-width: none;
    gap: 6px;
    overflow: visible;
  }
  .week-day {
    flex: 0 0 72px; width: 72px; min-height: 78px; padding: 6px 4px;
    scroll-snap-align: start;
  }
  .week-day-name { font-size: 10px; }
  .week-day-date { font-size: 8px; letter-spacing: -0.02em; }
  .week-day-count { font-size: 15px; }
  .week-day-note { font-size: 9px; }
  .week-day-stores { display: none; }
  .week-day-detail {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
}
@media (max-width: 560px) {
  /* มือถือ: ลดขอบซ้าย–ขวา ให้เนื้อหาเต็มจอขึ้น */
  .topbar { padding: 10px 8px; }
  .main { padding: 8px; }
  .home-dash { gap: 10px; }
  .home-hero-combo { border-radius: 14px; }
  .home-block { border-radius: 14px; padding: 10px; }
  .home-store { padding: 12px; }
  .home-fold-summary { padding: 12px; }
  .home-fold-body { padding: 0 12px 12px; }
  .progress-hero { grid-template-columns: 1fr; justify-items: center; }
  .block-progress .summary-grid { width: 100%; }
  .home-hero-slider { aspect-ratio: 16 / 12; min-height: 200px; }
  .home-hero-progress {
    margin: -64px 6px 6px;
    padding: 10px;
  }
  .home-hero-progress .progress-hero {
    grid-template-columns: 84px 1fr;
    gap: 8px;
    justify-items: stretch;
  }
  .home-hero-progress .progress-ring-wrap,
  .home-hero-progress .progress-ring { width: 84px; height: 84px; }
  .home-hero-progress .progress-ring-center strong { font-size: 18px; }
  .home-hero-progress .stat span:not(.stat-ico) { font-size: 18px; }
}
.week-day-name { font-size: 11px; font-weight: 800; color: var(--rs-navy); }
.week-day.is-off .week-day-name { color: var(--rs-muted); }
.week-day-date {
  font-size: 9px; font-weight: 700; color: #546E7A; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.week-day.is-off .week-day-date { color: #90A4AE; }
.week-day-count { font-size: 18px; font-weight: 800; color: var(--rs-navy); line-height: 1.1; }
.week-day-note { font-size: 10px; color: var(--rs-muted); font-weight: 600; }
.week-day-stores { display: grid; gap: 3px; margin-top: 2px; }
.week-day-stores span {
  display: block; font-size: 9px; line-height: 1.25; color: #455a64;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.week-day-detail {
  margin-top: 8px; background: #fff; border: 1px solid var(--rs-border);
  border-radius: 14px; padding: 12px; display: none;
}
.week-day-detail.open { display: block; }
.week-day-detail h3 { margin: 0 0 8px; font-size: 14px; color: var(--rs-navy); }
.week-row {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--rs-border); font-size: 13px;
}
.week-row:last-child { border-bottom: 0; }
.week-row strong { color: var(--rs-navy); }
.week-row .t { font-weight: 700; color: #1565C0; white-space: nowrap; }

.week-manage {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}
.week-manage:not(:has(button:not([hidden]))) { display: none; }
.week-manage-panel {
  margin-top: 0; padding: 12px; border-radius: 14px;
  background: rgba(255,255,255,.85); border: 1px solid #CE93D8;
  display: grid; gap: 10px;
}
.week-manage-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.week-tab {
  border: 1px solid #CE93D8; background: #F3E5F5; color: #6A1B9A;
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 12px;
  font-weight: 700; cursor: pointer;
}
.week-tab.active { background: #6A1B9A; color: #fff; border-color: #6A1B9A; }
.week-tab-pane label {
  display: grid; gap: 4px; font-size: 12px; font-weight: 700; color: #6A1B9A;
}
.week-tab-pane input[type="date"] {
  border: 1px solid var(--rs-border); border-radius: 10px; padding: 10px;
  font: inherit; background: #fff;
}
.move-store-list { display: grid; gap: 6px; max-height: 180px; overflow: auto; }
.move-store-item {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--rs-border); border-radius: 10px;
  padding: 8px 10px; font-size: 13px;
}
.move-store-item input { width: 18px; height: 18px; }
.week-day.has-override::after {
  content: 'แก้'; position: absolute; top: 4px; right: 4px;
  font-size: 9px; font-weight: 800; color: #6A1B9A;
  background: #E1BEE7; border-radius: 6px; padding: 1px 4px;
}
.week-day { position: relative; }
.week-row-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.rules-fold {
  background: #fff; border: 1px solid var(--rs-border); border-radius: 14px; padding: 10px 14px;
}
.rules-fold summary {
  cursor: pointer; font-weight: 700; color: var(--rs-navy); list-style: none;
}
.rules-fold summary::-webkit-details-marker { display: none; }
.rules-fold ul { margin: 8px 0 0; padding-left: 18px; color: var(--rs-muted); font-size: 13px; }

.tip ul { margin: 8px 0 0; padding-left: 18px; color: var(--rs-muted); }
.tip li { margin-bottom: 4px; }

.screen-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.screen-head h2 { margin: 0; font-size: 18px; }
.link-back {
  border: 0; background: transparent; color: var(--rs-blue);
  font: inherit; font-weight: 600; padding: 0; cursor: pointer;
}

.store-list { display: grid; gap: 10px; }
.store-item {
  background: #fff; border: 1px solid var(--rs-border); border-radius: 14px;
  padding: 14px; display: grid; gap: 6px; text-align: left;
  width: 100%; font: inherit; cursor: pointer;
}
.store-item:hover { border-color: #bbd2f0; }
.store-item .meta { color: var(--rs-muted); font-size: 13px; }

/* Leave (Staff-style) */
.leave-panel {
  background: #fff; border: 1px solid var(--rs-border); border-radius: 16px;
  padding: 14px; margin-bottom: 12px;
  box-shadow: 0 4px 16px rgba(13, 71, 161, .05);
}
.leave-panel-hdr {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  margin-bottom: 12px;
}
.leave-panel-hdr strong {
  color: var(--rs-navy); font-size: 15px;
  display: inline-flex; align-items: center; gap: 8px;
}
.leave-sub { margin: 4px 0 0; font-size: 12px; }
.leave-year { font-weight: 700; opacity: .7; }
.leave-total-pill {
  background: #E3F2FD; color: var(--rs-navy); border-radius: 999px;
  padding: 6px 12px; font-size: 12px; font-weight: 800; white-space: nowrap;
}
.leave-quota-track {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  max-width: 100%;
  min-width: 0;
}
.leave-chip {
  flex: 0 0 132px; scroll-snap-align: start;
  border: 1px solid var(--rs-border); border-radius: 14px;
  padding: 12px 10px; background: #F8FAFF; text-align: left;
  font: inherit; cursor: pointer; display: grid; gap: 2px;
}
.leave-chip strong { font-size: 18px; color: var(--rs-navy); }
.leave-chip small { font-size: 11px; color: var(--rs-muted); font-weight: 600; }
.leave-chip-type { font-size: 12px; font-weight: 800; color: var(--rs-navy); }
.leave-chip-loading { flex: 1; text-align: center; color: var(--rs-muted); cursor: default; }
.leave-chip.tone-sick { background: #FEE2E2; border-color: #FECACA; }
.leave-chip.tone-personal { background: #FFEDD5; border-color: #FED7AA; }
.leave-chip.tone-annual { background: #DCFCE7; border-color: #BBF7D0; }
.leave-chip.tone-maternity { background: #FCE7F3; border-color: #FBCFE8; }
.leave-chip.tone-holiday { background: #E0E7FF; border-color: #C7D2FE; }
.leave-chip.tone-ordain { background: #EDE9FE; border-color: #DDD6FE; }
.leave-chip.tone-disaster { background: #FEF3C7; border-color: #FDE68A; }

#leave-disaster-box { display: grid; gap: 12px; }
#leave-disaster-box[hidden],
#leave-disaster-other-wrap[hidden] { display: none !important; }
.leave-form label {
  display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--rs-muted);
}
.leave-form input, .leave-form select, .leave-form textarea {
  border: 1px solid var(--rs-border); border-radius: 12px; padding: 12px;
  font: inherit; font-size: 15px; color: var(--rs-text); background: #fff;
}
.leave-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.leave-days-est {
  margin: 0; font-size: 13px; font-weight: 800; color: var(--rs-blue);
  background: #E3F2FD; border-radius: 10px; padding: 8px 12px;
}

.leave-list { display: grid; gap: 8px; }
.leave-item {
  border: 1px solid var(--rs-border); border-radius: 14px; padding: 12px;
  display: grid; gap: 6px; background: #fff;
}
.leave-item-top { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.leave-item .meta { color: var(--rs-muted); font-size: 13px; }
.leave-photo-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.leave-photo-grid:empty { display: none; }
.leave-photo-thumb {
  position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--rs-border); padding: 0; background: #f4f6f8;
}
.leave-photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.leave-photo-thumb button {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border: 0;
  border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; line-height: 20px;
}
.leave-hist-photos { display: flex; flex-wrap: wrap; gap: 6px; }
.leave-hist-photos button {
  width: 56px; height: 56px; padding: 0; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--rs-border); background: #f4f6f8;
}
.leave-hist-photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge-leave-pending { background: #FFF3E0; color: #EF6C00; }
.badge-leave-approved { background: #E8F5E9; color: #2E7D32; }
.badge-leave-rejected { background: #FFEBEE; color: #C62828; }
.badge-leave-cancelled { background: #ECEFF1; color: #546E7A; }
.btn-sm { padding: 8px 12px; font-size: 13px; width: fit-content; }

.badge {
  display: inline-block; border-radius: 999px; padding: 3px 10px;
  font-size: 12px; font-weight: 600;
}
.badge-pending { background: #FFF3E0; color: #EF6C00; }
.badge-checked_in { background: #E3F2FD; color: #1565C0; }
.badge-done { background: #E8F5E9; color: #2E7D32; }

.punch-layout { display: grid; gap: 12px; }
.punch-left { display: grid; gap: 12px; align-content: start; }
.gps-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gps-place {
  margin: 8px 0 4px; font-size: 14px; font-weight: 700; color: var(--rs-navy);
  line-height: 1.35;
}
.gps-place:empty { display: none; }
.gps-mismatch {
  margin-top: 10px; padding: 10px; border-radius: 12px;
  background: #FFF3E0; border: 1px solid #FFCC80;
}
.gps-mismatch-text {
  margin: 0; font-size: 13px; font-weight: 700; color: #E65100;
  display: flex; gap: 8px; align-items: center;
}
.gps-far #gps-status { color: #E65100; font-weight: 700; }
.gps-ok-near #gps-status { color: #2E7D32; font-weight: 700; }

#cam, #photo-preview {
  width: 100%; max-height: 280px; border-radius: 12px; background: #111; object-fit: cover;
}
#cam.cam-front {
  transform: scaleX(-1);
}
.cam-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 8px;
}
.cam-hint {
  margin: 0; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.row-gap { display: flex; gap: 8px; margin-top: 10px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--rs-blue);
  padding: 8px 0 calc(8px + var(--safe-bottom));
  z-index: 30;
}
.bottom-nav.has-admin,
.bottom-nav:has(.nav-admin:not([hidden])) {
  grid-template-columns: repeat(4, 1fr);
}
.nav-item {
  border: 0; background: transparent; color: rgba(255,255,255,.75);
  display: grid; gap: 2px; justify-items: center;
  font: inherit; font-size: 11px; padding: 6px; cursor: pointer;
  text-decoration: none;
}
/* สำคัญ: .nav-item { display:grid } ทับ UA [hidden] — พนักงานต้องไม่เห็นเมนูจัดการ */
.nav-item[hidden],
a.nav-item[hidden] {
  display: none !important;
}
.nav-item i { font-size: 18px; }
.nav-item.active { color: #fff; font-weight: 700; }
a.nav-item { color: rgba(255,255,255,.75); }
.zone-banner {
  display: flex; gap: 12px; align-items: flex-start;
  background: #E3F2FD; color: #0D47A1; border: 1px solid #90CAF9;
}
.zone-banner[hidden] { display: none !important; }
.zone-banner i { font-size: 20px; margin-top: 2px; }
.zone-banner strong { display: block; }
.zone-banner span { font-weight: 500; font-size: 12px; opacity: .92; line-height: 1.35; }
.zone-banner-copy { min-width: 0; flex: 1; display: grid; gap: 4px; }
.zone-banner-more {
  justify-self: start; border: 0; background: rgba(13,71,161,.12);
  color: inherit; font: inherit; font-size: 11px; font-weight: 700;
  padding: 4px 8px; border-radius: 999px; cursor: pointer;
}
.zone-banner-full { font-weight: 500; font-size: 12px; opacity: .92; line-height: 1.4; }
.sup-home-actions {
  display: grid; gap: 8px; margin: 0 0 12px;
}
.sup-home-actions[hidden] { display: none !important; }
.mg-extra-actions {
  display: grid; gap: 8px; margin: 0 0 12px;
}
.mg-extra-actions[hidden] { display: none !important; }
.badge-off-sched {
  background: #FFF3E0; color: #E65100;
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 999px;
}
.badge-out-area {
  background: #F3E5F5; color: #6A1B9A;
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 999px;
}
#mg-place-note {
  width: 100%; min-height: 72px;
  border: 1px solid var(--border, #CFD8DC);
  border-radius: 12px; padding: 10px 12px;
  font: inherit; resize: vertical;
}
.sup-pick-filters {
  display: grid; gap: 10px; margin-bottom: 10px;
}
.sup-pick-filters[hidden] { display: none !important; }
.sup-pick-filters label {
  display: grid; gap: 4px; font-size: 12px; font-weight: 700; color: var(--rs-navy);
}
.sup-pick-filters select {
  width: 100%; min-height: 42px; border-radius: 12px;
  border: 1px solid #CFD8DC; background: #F7FAFC; color: var(--rs-navy);
  padding: 0 10px; font: inherit; font-size: 14px; font-weight: 600;
}
.sup-day-radio {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid #90A4AE;
  margin-top: 2px; flex-shrink: 0; background: #fff;
}
.sup-day-pick.on .sup-day-radio {
  border-color: #1565C0; box-shadow: inset 0 0 0 4px #1565C0;
}
button.sup-day-pick {
  width: 100%; text-align: left; font: inherit; cursor: pointer;
  display: flex; align-items: flex-start; gap: 10px;
}

/* Mobile drawer */
.mobile-menu {
  position: fixed; inset: 0; z-index: 40;
  pointer-events: none; visibility: hidden;
}
.mobile-menu.open { pointer-events: auto; visibility: visible; }
.mobile-menu-backdrop {
  position: absolute; top: var(--mobile-menu-offset); left: 0; right: 0; bottom: 0;
  background: rgba(10,22,40,.5); opacity: 0; transition: opacity .28s ease;
}
.mobile-menu.open .mobile-menu-backdrop { opacity: 1; }
.mobile-menu-panel {
  position: absolute; top: var(--mobile-menu-offset); left: 0; right: 0;
  max-height: min(calc(88vh - 62px), 520px); overflow-y: auto;
  background: linear-gradient(180deg, var(--rs-navy) 0%, #0f2744 100%);
  color: #fff; border-radius: 0 0 22px 22px;
  box-shadow: 0 16px 48px rgba(0,0,0,.35);
  transform: translateY(-105%);
  transition: transform .34s cubic-bezier(.4,0,.2,1);
}
.mobile-menu.open .mobile-menu-panel { transform: translateY(0); }
.mobile-menu-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.mobile-menu-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mobile-menu-logo { width: 44px; height: 44px; flex-shrink: 0; }
.mobile-menu-title { font-weight: 800; font-size: 16px; }
.mobile-menu-sub { font-size: 11px; opacity: .65; margin-top: 2px; }
.mobile-menu-close {
  width: 38px; height: 38px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.1); color: #fff; font-size: 18px;
}
.mobile-menu-nav { display: flex; flex-direction: column; gap: 4px; padding: 12px; }
.mobile-menu-nav .nav-item {
  display: flex; align-items: center; gap: 12px; justify-items: start;
  width: 100%; padding: 13px 14px; border-radius: 12px;
  font-size: 15px; font-weight: 600; color: rgba(255,255,255,.85);
  grid-template-columns: none; text-align: left;
}
.mobile-menu-nav .nav-item i { width: 20px; text-align: center; }
.mobile-menu-nav .nav-item.active {
  background: rgba(33,150,243,.22); color: #fff; border-left: 3px solid #4fc3f7; padding-left: 11px;
}
.mobile-menu-foot { border-top: 1px solid rgba(255,255,255,.1); padding: 14px 16px 18px; }
.mobile-menu-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.mobile-menu-avatar, .sidebar-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #2196F3, #0D47A1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; border: 2px solid #4fc3f7; flex-shrink: 0;
  overflow: hidden;
}
.mobile-menu-avatar.has-photo, .sidebar-avatar.has-photo {
  padding: 0; background: #fff;
}
.mobile-menu-avatar img, .sidebar-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

.profile-hero {
  display: flex; gap: 14px; align-items: center; margin-bottom: 16px;
}
.profile-photo-wrap { position: relative; flex-shrink: 0; }
.profile-photo-wrap img,
.profile-photo-placeholder {
  width: 88px; height: 88px; border-radius: 50%;
  object-fit: cover; display: block;
  border: 3px solid #BBDEFB; background: #E3F2FD;
}
.profile-photo-placeholder {
  display: grid; place-items: center; color: var(--rs-blue); font-size: 32px;
}
.profile-photo-btn {
  position: absolute; right: 0; bottom: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--rs-blue); color: #fff;
  display: grid; place-items: center; cursor: pointer;
  border: 2px solid #fff; font-size: 13px;
}
.profile-hero-text h3 { margin: 0 0 4px; color: var(--rs-navy); font-size: 18px; }
.profile-hero-text .muted { margin: 2px 0; font-size: 13px; }
.profile-form { display: grid; gap: 12px; }
.profile-form label {
  display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--rs-muted);
}
.profile-form input, .profile-form textarea {
  border: 1px solid var(--rs-border); border-radius: 12px; padding: 12px;
  font: inherit; font-size: 15px; color: var(--rs-text); background: #fff;
}
.profile-ok {
  margin: 0; text-align: center; font-weight: 700; color: var(--rs-ok);
  background: #E8F5E9; border-radius: 10px; padding: 8px;
}
.profile-pin-box {
  margin-top: 16px; padding: 14px; border-radius: 14px;
  border: 1px solid #BBDEFB; background: linear-gradient(180deg, #E3F2FD, #fff);
}
.profile-pin-box .block-label { color: var(--rs-navy); margin-bottom: 4px; }
.profile-pin-box .profile-form { margin-top: 8px; }

.mobile-menu-uname, .sidebar-uname { font-size: 13px; font-weight: 700; }
.mobile-menu-urole, .sidebar-urole { font-size: 11px; opacity: .65; }
.mobile-menu-logout, .sidebar-logout {
  width: 100%; padding: 12px; border: 1px solid rgba(255,255,255,.15); border-radius: 12px;
  background: rgba(255,255,255,.06); color: rgba(255,255,255,.88);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

@media (min-width: 960px) {
  /* หน้าคอม: ตรึงเมนูซ้าย · เลื่อนเฉพาะเนื้อหาหลัก (โครงเดียวกับ Route) */
  .menu-btn, .logout-mobile-btn, .bottom-nav { display: none !important; }
  .mobile-menu { display: none !important; }

  body:has(#view-app.active) {
    height: 100vh;
    overflow: hidden;
  }

  #view-login.active {
    display: grid; place-items: center; min-height: 100%;
    padding: 40px 24px;
    background: radial-gradient(ellipse at top left, rgba(33,150,243,.18), transparent 50%), var(--rs-bg);
  }
  #view-login .login-hero {
    border-radius: 16px 16px 0 0; max-width: 440px; width: 100%; margin: 0 auto;
  }
  #view-login .login-card { max-width: 440px; width: 100%; margin: -28px auto 0; }
  #btn-install-login { max-width: 440px; margin-left: auto; margin-right: auto; }

  #view-app.active {
    display: grid !important;
    grid-template-columns: var(--rs-sidebar-w) minmax(0, 1fr);
    grid-template-rows: 100vh;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    width: 100%;
    background: var(--rs-bg);
    padding-bottom: 0;
  }

  #view-app.active > .mobile-menu,
  #view-app.active > .bottom-nav {
    display: none !important;
  }

  #view-app.active > .sidebar {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    grid-column: 1;
    grid-row: 1;
    align-self: stretch;
    box-sizing: border-box;
    width: var(--rs-sidebar-w);
    height: 100%;
    max-height: 100vh;
    margin: 0;
    padding: 18px 14px;
    background: linear-gradient(180deg, #0D47A1, #0A3A8A);
    color: #fff;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .sidebar-brand {
    display: flex !important;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    padding: 4px 6px 14px;
    margin: 0;
    border-bottom: 1px solid rgba(255,255,255,.15);
    color: #fff;
  }
  .sidebar-logo {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 12px;
    background: #fff;
    object-fit: contain;
    padding: 6px;
    box-sizing: border-box;
  }
  .mobile-menu-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #fff;
    object-fit: contain;
    padding: 5px;
    box-sizing: border-box;
  }
  .sidebar-title {
    font-weight: 800; font-size: 15px; letter-spacing: .4px;
    color: #fff !important;
  }
  .sidebar-sub {
    font-size: 11px; opacity: .7; margin-top: 2px;
    color: #fff !important;
  }

  .sidebar-nav {
    display: grid !important;
    gap: 6px;
    flex: 1 1 auto;
    overflow: auto;
    align-content: start;
    min-height: 0;
  }
  .sidebar .nav-item {
    display: flex !important;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    box-sizing: border-box;
    padding: 13px 14px;
    border-radius: 12px;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    color: rgba(255,255,255,.88) !important;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    grid-template-columns: none;
    justify-content: flex-start;
  }
  .sidebar .nav-item i {
    width: 20px; text-align: center; font-size: 16px; color: inherit;
  }
  .sidebar .nav-item span { color: inherit; }
  .sidebar .nav-item:hover { background: rgba(255,255,255,.12); color: #fff !important; }
  .sidebar .nav-item.active {
    background: rgba(33,150,243,.22);
    color: #fff !important;
    font-weight: 700;
    border-left: 3px solid #4fc3f7;
    padding-left: 11px;
  }
  .sidebar .nav-item[hidden] { display: none !important; }

  .sidebar-foot {
    flex-shrink: 0;
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,.12);
    padding-top: 12px;
    display: grid;
    gap: 8px;
  }
  .sidebar-user {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 0; padding: 0 6px;
  }
  .sidebar-uname { font-size: 14px; font-weight: 700; line-height: 1.3; }
  .sidebar-urole { font-size: 12px; opacity: .75; margin-top: 2px; }
  .sidebar-logout {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 12px;
    background: rgba(255,255,255,.06);
    color: rgba(255,255,255,.88);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  #view-app.active > .app-body {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    height: 100%;
    max-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--rs-bg);
    display: flex;
    flex-direction: column;
  }

  .topbar {
    background: #fff;
    color: var(--rs-text);
    border-bottom: 1px solid var(--rs-border);
    padding: 14px 24px;
    position: sticky;
    top: 0;
    z-index: 5;
    flex-shrink: 0;
  }
  .topbar-user:active { background: #eef3fb; }
  .topbar-avatar { border-color: #bbdefb; background: #e3f2fd; color: var(--rs-navy); }
  .topbar-title strong { color: var(--rs-navy); font-size: 18px; }
  .topbar-title span { color: var(--rs-muted); }
  .icon-btn { background: #eef3fb; color: var(--rs-navy); }
  .notif-btn .notif-badge { box-shadow: 0 0 0 2px #fff; }

  .main {
    padding: 20px 24px 40px;
    max-width: none;
    width: 100%;
    box-sizing: border-box;
    flex: 1 0 auto;
  }
  .main .card,
  .main .home-block,
  .main .block-work,
  .main .sup-month-wrap,
  .zone-banner {
    border-radius: 14px;
  }

  .summary-grid { gap: 14px; }
  .stat { padding: 20px 12px; }
  .stat span { font-size: 36px; }
  .home-store-list { grid-template-columns: repeat(2, minmax(0, 1fr)); display: grid; }
  .store-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .week-plan { gap: 10px; }
  .week-day { min-height: 120px; padding: 12px; }
  .week-day-stores span { font-size: 11px; }
  .punch-layout { grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
  #cam, #photo-preview { max-height: 360px; }

  #screen-profile .card,
  #screen-leave .card {
    max-width: 720px;
  }
}





.acc-fill-btn{
  display:none;align-items:center;justify-content:center;gap:8px;
  width:calc(100% - 24px);box-sizing:border-box;margin:8px 12px 0;padding:12px 16px;
  border:none;border-radius:14px;text-decoration:none;text-align:center;
  font-family:inherit;font-size:16px;font-weight:800;color:#fff;
  background:linear-gradient(180deg,#1565C0,#0D47A1);
  box-shadow:0 6px 16px rgba(13,71,161,.28);
}
body.role-supervisor .acc-fill-btn{display:flex}
.acc-fill-btn:hover{color:#fff}

.acc-sup-menu{display:inline-flex;align-items:center;justify-content:center;gap:8px;margin-top:8px}

/* reports tab (2026-11-03): bottom nav columns follow visible items */
.bottom-nav, .bottom-nav.has-admin, .bottom-nav:has(.nav-admin:not([hidden])) { grid-template-columns: none !important; grid-auto-flow: column; grid-auto-columns: 1fr; }
