:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-soft: #f1f6fb;
  --ink: #223041;
  --muted: #6b7a90;
  --line: #dbe5ef;
  --primary: #80caff;
  --primary-dark: #2f80b9;
  --primary-soft: #e5f5ff;
  --sidebar: #d9efff;
  --sidebar-ink: #17354d;
  --danger: #dc4c64;
  --warning: #f2a23a;
  --success: #39a96b;
  --purple: #8d72e1;
  --black: #3e4652;
  --shadow: 0 18px 45px rgba(31, 50, 72, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: 'Sarabun', 'Kanit', sans-serif; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary-dark); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.full-btn { width: 100%; }
.setup-warning { position: fixed; z-index: 50; top: 14px; left: 50%; transform: translateX(-50%); background: #fff4d8; border: 1px solid #ffd27b; color: #6b4a00; padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; }
.auth-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 20%, #e6f6ff 0, transparent 34%), radial-gradient(circle at 85% 10%, #eaf1ff 0, transparent 28%), var(--bg); }
.auth-card { width: min(560px, 100%); background: rgba(255,255,255,.9); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,.8); border-radius: 30px; padding: 34px; box-shadow: var(--shadow); }
.brand-mark { width: 74px; height: 74px; border-radius: 24px; background: linear-gradient(135deg, var(--primary), #cbeaff); display: grid; place-items: center; font-weight: 800; color: #11405f; margin-bottom: 16px; }
.auth-card h1 { margin: 0 0 8px; font-size: 28px; line-height: 1.25; }
.auth-tabs { display: grid; grid-template-columns: minmax(150px, .85fr) minmax(250px, 1.15fr); gap: 8px; background: var(--panel-soft); padding: 6px; border-radius: 18px; margin: 22px 0; }
.auth-tab { border: 0; background: transparent; color: var(--muted); padding: 12px 10px; border-radius: 13px; font-weight: 800; line-height: 1.25; white-space: normal; word-break: keep-all; }
.auth-tab.active { background: #fff; color: var(--primary-dark); box-shadow: 0 4px 14px rgba(31, 50, 72, 0.08); }
.auth-panel { display: none; }
.auth-panel.active { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: #344458; font-weight: 700; }
input, select, textarea { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fff; color: var(--ink); outline: none; min-width: 0; }
textarea { min-height: 86px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(128,202,255,.22); }
.primary-btn, .ghost-btn, .danger-ghost, .soft-btn { border: 0; border-radius: 15px; min-height: 44px; padding: 10px 16px; font-weight: 800; transition: .18s ease; }
.primary-btn { background: var(--primary); color: #12364f; }
.primary-btn:hover { filter: brightness(.98); transform: translateY(-1px); }
.ghost-btn { background: #fff; color: var(--primary-dark); border: 1px solid var(--line); }
.soft-btn { background: var(--primary-soft); color: var(--primary-dark); }
.danger-ghost { background: #fff; color: var(--danger); border: 1px solid #ffd3dc; }
.icon-btn { width: 44px; height: 44px; border: 1px solid var(--line); background: #fff; border-radius: 14px; }
.app-view { display: grid; grid-template-columns: 292px 1fr; min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--sidebar), #eef8ff); border-right: 1px solid rgba(23,53,77,.08); padding: 20px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; color: var(--sidebar-ink); }
.sidebar-head { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.brand-icon { width: 48px; height: 48px; border-radius: 17px; background: #fff; color: var(--primary-dark); display: grid; place-items: center; font-weight: 900; box-shadow: 0 8px 20px rgba(31,80,120,.1); }
.app-title { font-weight: 900; font-size: 20px; }
.app-subtitle { color: rgba(23,53,77,.68); font-size: 13px; }
.main-nav { display: grid; gap: 6px; overflow: auto; padding-right: 4px; }
.nav-btn { width: 100%; border: 0; background: transparent; color: rgba(23,53,77,.82); display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 17px; font-weight: 800; text-align: left; transition: .18s ease; }
.nav-btn:hover { background: rgba(255,255,255,.55); }
.nav-btn.active { background: #fff; color: #113b58; box-shadow: 0 10px 24px rgba(31, 72, 110, 0.10); }
.nav-emoji { width: 22px; text-align: center; }
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; }
.user-mini { background: rgba(255,255,255,.7); border: 1px solid rgba(255,255,255,.8); border-radius: 20px; padding: 12px; font-size: 14px; }
.main-panel { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(246,248,251,.86); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); padding: 18px 24px; display: flex; align-items: center; gap: 16px; }
.topbar h2 { margin: 0; font-size: 24px; }
.topbar p { margin: 2px 0 0; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sync-status { font-size: 13px; color: var(--muted); }
.page-content { padding: 24px; display: grid; gap: 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 10px 24px rgba(31, 50, 72, 0.06); padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 18px; }
.stat-card { display: grid; gap: 6px; }
.stat-card .num { font-size: 34px; font-weight: 900; color: var(--primary-dark); line-height: 1; }
.stat-card .label { color: var(--muted); font-weight: 700; }
.section-title { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f6f9fc; font-weight: 900; color: #405169; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 900; background: var(--panel-soft); color: #42546a; white-space: nowrap; }
.badge.green { background: #e5f7ed; color: #19774b; }
.badge.blue { background: #e6f4ff; color: #2370a5; }
.badge.orange { background: #fff0dc; color: #a96100; }
.badge.purple { background: #f0eaff; color: #6750b8; }
.badge.red { background: #ffe9ee; color: #b3354c; }
.badge.yellow { background: #fff7d8; color: #806000; }
.badge.black { background: #eceff3; color: #303946; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tiny-btn { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 7px 10px; font-weight: 800; color: var(--primary-dark); }
.tiny-btn.danger { color: var(--danger); border-color: #ffd3dc; }
.tiny-btn.warn { color: #9b6a00; border-color: #ffd27b; background: #fffaf0; }
.tiny-btn.success { color: #0f7a3b; border-color: #b8e7c6; background: #f2fff6; }
.calendar-shell { display: grid; gap: 14px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(110px,1fr)); gap: 8px; }
.calendar-dayname { color: var(--muted); font-weight: 900; text-align: center; padding: 8px; }
.calendar-cell { min-height: 126px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.calendar-cell.other-month { opacity: .45; }
.calendar-cell.today { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(128,202,255,.18); }
.day-num { font-weight: 900; display: flex; justify-content: space-between; align-items: center; }
.event-pill { border: 0; border-radius: 10px; padding: 5px 7px; font-size: 12px; font-weight: 800; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-leave { background: #e5f7ed; color: #19774b; }
.event-training { background: #e6f4ff; color: #2370a5; }
.event-meeting { background: #fff0dc; color: #a96100; }
.event-noduty { background: #f0eaff; color: #6750b8; }
.event-outing { background: #ffe9ee; color: #b3354c; }
.event-holiday { background: #fff7d8; color: #806000; }
.event-duty { background: #eceff3; color: #303946; }
.week-list, .day-list { display: grid; gap: 10px; }
.timeline-item { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: flex; justify-content: space-between; gap: 12px; }
.roster-board { display: grid; grid-template-columns: 250px 1fr; gap: 16px; align-items: start; }
.staff-pool { display: grid; gap: 8px; max-height: 68vh; overflow: auto; }
.staff-chip { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 10px; font-weight: 800; display: flex; justify-content: space-between; gap: 8px; }
.staff-chip[draggable="true"] { cursor: grab; }
.roster-table td { min-width: 118px; }
.roster-slot { min-height: 48px; border: 1px dashed #bfd7ea; border-radius: 14px; padding: 8px; background: #fbfdff; display: grid; gap: 5px; }
.roster-slot.drag-over { background: var(--primary-soft); border-color: var(--primary); }
.assigned-name { font-weight: 900; color: #24445d; }
.slot-meta { color: var(--muted); font-size: 12px; }
.locked { opacity: .72; }
.print-only { display: none; }
.empty-state { padding: 24px; border: 1px dashed var(--line); border-radius: 20px; text-align: center; color: var(--muted); background: #fff; }
.modal { position: fixed; inset: 0; background: rgba(17, 30, 43, .36); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal-card { width: min(760px, 100%); max-height: 88vh; overflow: auto; background: #fff; border-radius: 26px; box-shadow: var(--shadow); padding: 24px; position: relative; }
.modal-close { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border: 0; border-radius: 14px; background: #f2f5f9; font-size: 24px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #203245; color: #fff; padding: 12px 16px; border-radius: 999px; box-shadow: var(--shadow); z-index: 110; }
.mobile-cards { display: none; }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .calendar-grid { grid-template-columns: repeat(7, minmax(90px,1fr)); }
  .roster-board { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .auth-card { padding: 24px; }
  .auth-tabs { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app-view { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 300px; max-width: 88vw; z-index: 80; transform: translateX(-105%); transition: .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .topbar { padding: 14px; }
  .topbar-actions { display: none; }
  .page-content { padding: 14px; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .calendar-grid { display: block; }
  .calendar-dayname { display: none; }
  .calendar-cell { min-height: auto; margin-bottom: 8px; }
  .table-wrap.desktop-table { display: none; }
  .mobile-cards { display: grid; gap: 10px; }
  .mobile-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: grid; gap: 8px; }
}
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .toolbar, .actions, .no-print { display: none !important; }
  .app-view { display: block; }
  .page-content { padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .print-only { display: block; }
  table { min-width: 0; font-size: 12px; }
}

/* V10 refinements */
.field-label { font-weight: 900; margin-bottom: 8px; color: #263746; }
.participant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 18px; padding: 10px; background: #fbfdff; }
.check-pill { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 9px 10px; font-weight: 800; cursor: pointer; }
.check-pill input { width: auto; }
.check-pill small { color: var(--muted); font-weight: 800; }
.compact-form { grid-template-columns: repeat(4, minmax(0,1fr)); align-items: end; }
.chip-line { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.notice { background: #fff7d8; color: #725800; border: 1px solid #ffe7a3; border-radius: 18px; padding: 12px 14px; font-weight: 800; margin: 10px 0; }
details { margin-top: 12px; }
details summary { cursor: pointer; font-weight: 900; color: var(--primary-dark); }
@media (max-width: 820px) {
  .compact-form { grid-template-columns: 1fr; }
  .participant-grid { grid-template-columns: 1fr 1fr; max-height: 320px; }
}
@media (max-width: 560px) {
  .participant-grid { grid-template-columns: 1fr; }
}

/* V11 daily position eligibility */
.soft-notice { background: #eef7ff; color: #285a7e; border-color: #cce8ff; }
.eligibility-wrap { max-height: 68vh; }
.eligibility-table th, .eligibility-table td { text-align: center; vertical-align: middle; min-width: 112px; }
.eligibility-table th small { display: block; color: var(--muted); font-size: 11px; font-weight: 700; line-height: 1.25; }
.eligibility-table .sticky-col { position: sticky; left: 0; z-index: 3; background: #fff; min-width: 170px; text-align: left; box-shadow: 8px 0 16px rgba(15, 35, 52, .06); }
.eligibility-table thead .sticky-col { z-index: 4; background: #f5f8fb; }
.eligibility-cell label { display: inline-flex; align-items: center; gap: 5px; justify-content: center; font-weight: 900; color: var(--primary-dark); }
.eligibility-cell input { width: auto; }
.eligibility-cell.rule-mismatch { background: #fff8f0; }
.eligibility-cell.rule-mismatch label { color: #a86800; }
@media (max-width: 820px) {
  .eligibility-table th, .eligibility-table td { min-width: 96px; font-size: 12px; }
  .eligibility-table .sticky-col { min-width: 130px; }
}

/* V12 navigation groups, staff colors, easier eligibility, audit filter */
.nav-section { display: grid; gap: 6px; margin-bottom: 14px; }
.nav-section-title { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px 4px; color: #496174; font-weight: 900; letter-spacing: .01em; }
.nav-section-title small { color: var(--muted); font-size: 11px; font-weight: 800; }
.staff-color-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 42px; border-radius: 999px; padding: 6px 12px; background: var(--staff-bg, #e8f3ff); color: var(--staff-fg, #203245); border: 1px solid rgba(31,50,69,.14); font-weight: 900; line-height: 1; white-space: nowrap; box-shadow: 0 1px 0 rgba(255,255,255,.55) inset; }
.staff-pill-btn { cursor: pointer; font-family: inherit; font-size: 13px; }
.staff-pill-btn:hover { filter: brightness(.97); transform: translateY(-1px); }
.staff-chip { background: var(--staff-bg, #fff); color: var(--staff-fg, #203245); border-color: rgba(31,50,69,.16); }
.staff-chip .badge { background: rgba(255,255,255,.72); color: #203245; }
.mini-profile .staff-color-pill { margin-bottom: 6px; }
.color-input { width: 52px; height: 34px; padding: 2px; border-radius: 10px; }
.eligibility-page { grid-template-columns: 320px minmax(0,1fr); align-items: start; }
.eligibility-staff-panel { position: sticky; top: 92px; }
.selected-staff-card { margin-top: 14px; border-radius: 22px; padding: 18px; background: var(--staff-bg, #e8f3ff); color: var(--staff-fg, #203245); font-weight: 800; display: grid; gap: 6px; border: 1px solid rgba(31,50,69,.12); }
.big-staff-name { font-size: 28px; font-weight: 900; }
.position-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.position-zone-card { border: 1px solid var(--line); border-radius: 20px; background: #fbfdff; padding: 14px; display: grid; gap: 8px; }
.position-zone-card h4 { margin: 0 0 4px; color: #263746; }
.position-check { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 12px; cursor: pointer; }
.position-check input { width: auto; margin-top: 3px; }
.position-check span { display: grid; gap: 3px; }
.position-check small { color: var(--muted); font-weight: 800; }
.position-check em { color: #4d6075; font-style: normal; font-size: 12px; line-height: 1.35; }
.position-check.checked { border-color: #91d1ff; background: #eef7ff; }
.position-check.rule-mismatch { background: #fff8f0; border-color: #ffdba9; }
.position-check.rule-mismatch small { color: #a86800; }
#auditDateInput { min-width: 180px; }
@media (max-width: 1100px) {
  .eligibility-page { grid-template-columns: 1fr; }
  .eligibility-staff-panel { position: static; }
  .position-card-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .nav-section-title { padding-left: 8px; }
  .staff-color-pill { padding: 6px 10px; min-width: 36px; }
}

/* V13 duty rules + readable schedule + monthly position planning */
.event-leave-vacation { background: #e5f7ed; color: #19774b; }
.event-leave-personal { background: #f0eaff; color: #6750b8; }
.event-leave-sick { background: #fff7d8; color: #806000; }
.event-leave-other { background: #e6f4ff; color: #2370a5; }
.event-standard { background: #f0eaff; color: #6750b8; }
.event-code { background: #fff7d8; color: #806000; }
.schedule-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 8px; margin: 12px 0 16px; }
.summary-chip { border-radius: 16px; padding: 10px 12px; background: var(--staff-bg); color: var(--staff-fg); border: 1px solid rgba(31,50,69,.12); display: grid; gap: 2px; box-shadow: 0 1px 0 rgba(255,255,255,.5) inset; }
.summary-chip span { font-size: 12px; font-weight: 800; opacity: .86; }
.schedule-readable { min-width: 980px; font-size: 14px; }
.schedule-readable th { top: 0; z-index: 2; text-align: center; }
.schedule-readable td { text-align: center; vertical-align: middle; }
.schedule-readable .date-cell { text-align: left; min-width: 98px; background: #fbfdff; position: sticky; left: 0; z-index: 1; box-shadow: 8px 0 18px rgba(15, 35, 52, .04); }
.schedule-readable tr.weekend-row td { background: #fcfbff; }
.schedule-readable tr.holiday-row td { background: #fffaf0; }
.month-position-preview table { min-width: 760px; }
.month-position-preview td, .month-position-preview th { vertical-align: middle; }
.monthly-position-page .notice { margin: 12px 0; }
@media (max-width: 820px) {
  .schedule-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .schedule-readable { font-size: 12px; }
  .schedule-readable .staff-color-pill { min-width: 34px; padding: 5px 8px; }
}

/* V14 monthly position matrix */
.monthly-position-page .notice { margin: 10px 0; }
.monthly-matrix-wrap { display: grid; gap: 10px; }
.matrix-legend { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 13px; font-weight: 800; }
.legend-box { width: 18px; height: 18px; border-radius: 5px; display: inline-block; border: 1px solid var(--line); }
.legend-box.weekend { background: #d6dbe1; }
.legend-box.outing { background: #ffe9ee; }
.legend-box.leave { background: #fff7d8; }
.month-position-matrix table { min-width: 1500px; border-collapse: separate; border-spacing: 0; }
.month-position-matrix th, .month-position-matrix td { padding: 8px 10px; min-width: 92px; text-align: center; vertical-align: middle; }
.month-position-matrix .sticky-col { position: sticky; left: 0; z-index: 3; box-shadow: 4px 0 10px rgba(31,50,72,.08); }
.month-position-matrix thead .sticky-col { z-index: 5; background: #f6f9fc; }
.month-position-matrix .staff-col { min-width: 150px; text-align: left; }
.month-position-matrix .date-head { font-size: 12px; line-height: 1.2; }
.month-position-matrix .weekend-head, .month-position-matrix .holiday-head { background: #d6dbe1; color: #1f2933; }
.month-position-matrix .outing-head { background: #ffe9ee; color: #b3354c; }
.matrix-cell { font-size: 12px; font-weight: 900; line-height: 1.25; background: #fff; }
.matrix-cell span { display: inline-block; white-space: nowrap; }
.matrix-cell.no-position-day { background: #d6dbe1; color: #4a5562; font-size: 11px; letter-spacing: .04em; }
.matrix-cell.outing-cell { background: #fff1f4; color: #b3354c; }
.matrix-cell.leave-cell { background: #fff7d8; color: #806000; }
.cell-note { margin-top: 4px; font-size: 10px; color: var(--muted); font-weight: 800; }
.staff-color-cell small { opacity: .85; }
@media (max-width: 720px) {
  .month-position-matrix th, .month-position-matrix td { min-width: 82px; padding: 7px 8px; font-size: 11px; }
  .month-position-matrix .staff-col { min-width: 124px; }
}

/* V15 duty trade + clearer roster cells */
.schedule-person-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.trade-btn {
  font-size: 11px;
  padding: 4px 8px;
  opacity: 0.92;
}
.trade-panel {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(120, 145, 170, .18);
}
.trade-panel h3 { margin-bottom: 10px; }
.modal .form-grid textarea { min-height: 92px; }
@media (max-width: 900px) {
  .schedule-person-cell { justify-content: flex-start; }
  .trade-btn { width: 100%; }
}

/* V17: no blank monthly position cells */
.month-position-matrix .needs-review-cell { background: #fff4df; color: #8a5a00; font-weight: 800; }
.month-position-matrix .needs-review-cell span { display: inline-block; padding: 3px 8px; border-radius: 999px; background: rgba(255, 196, 87, .28); }

/* V19 roster usability + monthly position summary */
.roster-board > .card:first-child {
  position: sticky;
  top: 86px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow: auto;
}
.roster-board .table-wrap {
  max-height: calc(100vh - 230px);
  overflow: auto;
}
.roster-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
}
.month-position-summary {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fbfdff;
}
.month-position-summary h4 {
  margin: 0 0 6px;
  font-size: 16px;
}
.month-position-summary table {
  min-width: 920px;
}
.month-position-summary td,
.month-position-summary th {
  vertical-align: top;
  text-align: left;
}
.trade-swap-only .hint {
  display: block;
  margin-top: 6px;
}
@media (max-width: 1100px) {
  .roster-board > .card:first-child {
    position: static;
    max-height: none;
  }
  .roster-board .table-wrap {
    max-height: none;
  }
}

/* V20: compact monthly position summary */
.month-position-summary-hint {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f8fbff;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.month-position-summary-hint .hint { flex: 1 1 420px; }
.staff-summary-trigger {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
  font: inherit;
}
.staff-summary-trigger span {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.55);
  font-size: 10px;
  font-weight: 900;
}
.staff-summary-trigger:hover span { background: rgba(255,255,255,.82); }
.staff-summary-head {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 8px 0 14px;
}
.modal-stat-grid { margin: 10px 0; }
.modal-summary-grid { margin-top: 10px; }
.modal-summary-grid .card-lite table,
.compact-detail-table table { width: 100%; min-width: 0; }
.modal-summary-grid .card-lite td,
.compact-detail-table td,
.compact-detail-table th { text-align: left; vertical-align: top; padding: 8px 10px; }
@media (max-width: 720px) {
  .month-position-summary-hint { align-items: flex-start; }
  .modal-summary-grid { grid-template-columns: 1fr; }
}

/* V30 mobile usability fixes */
.sidebar-backdrop { display:none; }
@media (max-width: 820px) {
  body.sidebar-open::after { content:""; position:fixed; inset:0; background:rgba(17,30,43,.28); z-index:70; }
  .sidebar.open { box-shadow: 18px 0 50px rgba(20,40,60,.25); }
  .main-panel { width:100%; overflow-x:hidden; }
  .topbar { align-items:flex-start; }
  .topbar h2 { font-size: 24px; line-height: 1.15; }
  .page-content { overflow-x:hidden; }
  .card { padding:14px; border-radius:22px; overflow:hidden; }
  .toolbar { align-items:stretch; }
  .toolbar > label, .toolbar > button, .toolbar > .soft-btn, .toolbar > .ghost-btn, .toolbar > .primary-btn { width:100%; }
  input, select, textarea, button { font-size:16px; max-width:100%; }
  label { font-size:15px; }
  .grid, .grid-2, .grid-3, .grid-4 { width:100%; }
  .section-title { align-items:flex-start; flex-direction:column; }
  .notice { font-size:14px; line-height:1.5; }

  .desktop-schedule-table, .daily-position-table.desktop-table, .desktop-table { display:none !important; }
  .mobile-schedule-list, .mobile-position-list { display:grid; gap:12px; }
  .schedule-day-card, .position-mobile-card, .mobile-day-card { background:#fff; border:1px solid var(--line); border-radius:20px; padding:14px; display:grid; gap:10px; }
  .schedule-day-card.weekend-row { background:#f4f6f8; }
  .mobile-day-head { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
  .mobile-day-head b { font-size:24px; }
  .mobile-day-head span { color:var(--muted); font-weight:800; }
  .mobile-duty-line { display:grid; grid-template-columns: 72px 1fr auto; gap:8px; align-items:center; padding:8px 0; border-top:1px solid var(--line); }
  .mobile-duty-line:first-of-type { border-top:0; }
  .mobile-duty-line .trade-btn { grid-column: 2 / -1; width:max-content; }
  .position-mobile-card h3 { margin:0; font-size:18px; }
  .position-mobile-card p { margin:0; color:var(--muted); line-height:1.45; }
  .position-mobile-card label { display:grid; gap:8px; }

  .mobile-calendar-tools { display:grid; gap:8px; margin-bottom:10px; }
  .mobile-calendar-list { display:grid; gap:12px; }
  .calendar-shell .toolbar { display:grid; grid-template-columns: 1fr 1fr; }
  .calendar-shell .toolbar b { grid-column:1/-1; margin:0 !important; }
  .calendar-shell .toolbar button { width:100%; }
  .event-pill { white-space:normal; line-height:1.35; }

  .leave .table-wrap, .activities .table-wrap { max-width:100%; }
  .modal { padding:10px; place-items:end center; }
  .modal-card { width:100%; max-height:88vh; border-radius:24px 24px 0 0; padding:18px; }
  .modal-card .form-grid { grid-template-columns:1fr; }
  .trade-panel .table-wrap { display:none; }
  .trade-panel .mobile-cards { display:grid; }
}
@media (min-width: 821px) {
  .mobile-schedule-list, .mobile-position-list, .mobile-calendar-list, .mobile-calendar-tools { display:none; }
}


/* V32 mobile/admin polish */
.modal { align-items:center; justify-items:center; }
.modal.modal-sm .modal-card { width:min(520px, calc(100vw - 32px)); }
.confirm-box h2 { margin-top:0; }
.confirm-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:20px; }
.gps-help { margin-top:14px; }
.mobile-roster-select { display:none; margin-top:8px; width:100%; }
.audit-mobile-cards, .users-mobile-cards { display:none; }
.user-mobile-card { gap:10px; }

@media (max-width: 820px) {
  html, body { overflow-x:hidden; }
  .modal { padding:14px; place-items:center !important; align-items:center !important; }
  .modal-card { width:min(94vw, 720px) !important; max-height:82vh; border-radius:26px !important; padding:20px !important; }
  .modal.modal-sm .modal-card { width:min(92vw, 500px) !important; }
  .confirm-actions { display:grid; grid-template-columns:1fr 1fr; }
  .ot-page { grid-template-columns:1fr !important; }
  .ot-card .primary-btn { width:100%; min-height:54px; font-size:18px; }
  .audit-page-card .audit-desktop-table { display:none; }
  .audit-mobile-cards { display:grid !important; gap:12px; }
  .audit-toolbar { display:grid; grid-template-columns:1fr 1fr; }
  .audit-toolbar label { grid-column:1/-1; }
  .audit-mobile-card p { margin:4px 0; line-height:1.45; }
  .users-mobile-cards { display:grid !important; gap:12px; }
  .users-mobile-cards + .hint { margin-top:12px; }
  .users-mobile-cards .grid-2 { grid-template-columns:1fr 1fr !important; }
  .mobile-roster-select { display:block; }
  .roster-board { display:block; }
  .staff-pool { display:none; }
  .roster-slot .actions { justify-content:flex-start; }
  .roster-slot { min-width:150px; }
  .roster-table { min-width:760px; }
  .topbar { align-items:flex-start; }
  .topbar h2 { font-size:24px; line-height:1.15; }
  .page-content { padding:16px; }
}

/* V32: stronger app-like modal and mobile pages */
body.modal-open { overflow: hidden; }
.modal { z-index: 9999; background: rgba(17, 30, 43, .48); backdrop-filter: blur(3px); align-items: center !important; justify-items: center !important; place-items: center !important; }
.modal-card { border-radius: 28px !important; box-shadow: 0 28px 80px rgba(20, 35, 52, .32) !important; animation: modalPop .16s ease-out; }
.modal-close { z-index: 2; }
@keyframes modalPop { from { opacity: .5; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
.mobile-roster-cards { display: none; }
.ot-mobile-cards { display: none; }

@media (max-width: 820px) {
  .modal { padding: 18px !important; align-items: center !important; justify-items: center !important; place-items: center !important; }
  .modal-card { width: min(94vw, 680px) !important; max-height: 82vh !important; border-radius: 26px !important; padding: 20px !important; }
  .confirm-box p { font-size: 16px; line-height: 1.55; }

  .grid.grid-2:has(#leaveForm), .grid.grid-2:has(#activityForm) { grid-template-columns: 1fr !important; }
  #leaveForm, #activityForm, #newStaffForm, #otForm { grid-template-columns: 1fr !important; }
  .leave-desktop-table, .activity-desktop-table, .users-desktop-table, .audit-desktop-table, .ot-desktop-table, .roster-table-wrap { display: none !important; }
  .mobile-cards, .audit-mobile-cards, .users-mobile-cards, .ot-mobile-cards, .mobile-roster-cards { display: grid !important; gap: 12px; }
  .mobile-card { border-radius: 22px; padding: 16px; box-shadow: 0 8px 22px rgba(31,50,72,.05); }

  .roster-board > .card:first-child { display: none; }
  .roster-board > .card:last-child { padding: 12px; }
  .mobile-roster-slot { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
  .mobile-roster-slot:first-of-type { border-top: 0; padding-top: 0; }
  .mobile-roster-slot select { width: 100%; min-height: 48px; }
  .roster-day-card { background: #fff; }

  .audit-toolbar { display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px; }
  .audit-toolbar label { grid-column: 1 / -1; }
  .audit-page-card { overflow: hidden; }
  .audit-mobile-card { font-size: 15px; }

  .users-mobile-cards label { font-size: 14px; }
  .users-mobile-cards input, .users-mobile-cards select { min-height: 44px; }

  .ot-card { overflow: visible; }
  .ot-card h3 { font-size: 22px; }
  .ot-card .primary-btn { min-height: 56px; font-size: 18px; }

  .calendar-shell .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .calendar-shell .toolbar label, .calendar-shell .toolbar b { grid-column: 1 / -1; }
  .mobile-calendar-list { max-height: none; }

  .sidebar { max-width: 82vw; }
  body.sidebar-open::after { z-index: 70; }
}

/* V36: Staff Planner brand + mobile monthly roster views */
.app-title { letter-spacing: .2px; }
.mobile-schedule-tabs { display:none; }
.mobile-schedule-view { display:none; }
.mobile-schedule-person-list, .mobile-ot-summary-list { display:grid; gap:12px; }
.schedule-person-card, .ot-summary-card {
  border:1px solid var(--line);
  border-radius:22px;
  padding:14px;
  background:#fff;
  display:grid;
  gap:10px;
  text-align:left;
}
.schedule-person-card .person-card-head, .person-duty-line, .mobile-duty-line {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  border-bottom:1px solid var(--line);
  padding-bottom:8px;
}
.schedule-person-card .person-card-head { border-bottom:0; background:var(--staff-bg); color:var(--staff-fg); border-radius:16px; padding:10px 12px; }
.person-duty-line:last-child, .mobile-duty-line:last-child { border-bottom:0; padding-bottom:0; }
.ot-summary-card {
  background:var(--staff-bg);
  color:var(--staff-fg);
  border-color:rgba(20,35,52,.08);
  grid-template-columns:1.2fr .8fr .8fr 1fr;
  align-items:center;
  font-weight:800;
}
.mobile-schedule-matrix-wrap { max-height:72vh; border-radius:20px; }
.schedule-person-matrix { border-collapse:separate; border-spacing:0; min-width:920px; }
.schedule-person-matrix th, .schedule-person-matrix td { min-width:92px; text-align:center; vertical-align:middle; }
.schedule-person-matrix thead th { position:sticky; top:0; z-index:3; background:#f4f8fb; }
.schedule-person-matrix tbody th { position:sticky; left:0; z-index:2; background:var(--staff-bg); color:var(--staff-fg); min-width:126px; }
.schedule-person-matrix td.weekend-cell { background:#d7dde3; color:#425466; font-size:12px; font-weight:800; }
.schedule-person-matrix td.holiday-cell { background:#fff5cf; color:#715600; font-size:12px; font-weight:800; }
.schedule-person-matrix .trade-btn { display:block; margin:6px auto 0; }
@media (max-width: 820px) {
  .desktop-schedule-summary { display:none !important; }
  .mobile-schedule-tabs { display:grid; grid-template-columns:repeat(4, minmax(0, 1fr)); gap:8px; margin:10px 0 14px; }
  .mobile-schedule-tabs button { min-height:44px; padding:8px 6px; font-size:14px; }
  .desktop-schedule-table { display:none !important; }
  .mobile-schedule-view { display:block; }
  .trade-panel .desktop-table { display:none !important; }
  .trade-mobile-cards { display:grid !important; }
  .schedule-day-card { border-radius:24px; padding:18px; }
  .mobile-duty-line { align-items:flex-start; }
  .mobile-duty-line .trade-btn { margin-left:auto; }
  .ot-summary-card { grid-template-columns:1fr 1fr; gap:6px; }
  .ot-summary-card b { grid-column:1/-1; font-size:18px; }
  .schedule-page-card { padding:14px; }
}

/* V43: wording cleanup + compact filter/profile layout */
.compact-filter { margin-bottom: 12px; }
.compact-filter label { min-width: 210px; }
.hint.compact { line-height: 1.45; margin-top: 6px; }
.compact-summary {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfdff;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
#myProfilePage .card > div:not(.section-title),
.profile-info-row {
  line-height: 1.65;
}
#myProfilePage .card b { margin-right: 4px; }
.staff-chip[data-staff-stat] { cursor: pointer; }
.trade-panel .notice { margin-top: 8px; }
@media (max-width: 820px) {
  .compact-filter { display: grid; grid-template-columns: 1fr; }
  .compact-filter label { min-width: 0; width: 100%; }
  .compact-summary { align-items: flex-start; }
  .gps-help.compact { font-size: 13px; }
}
.profile-info-grid { display:grid; gap:10px; margin: 8px 0 18px; }
.profile-info-grid > div { display:grid; grid-template-columns: 110px minmax(0,1fr); gap:12px; align-items:baseline; padding:7px 0; border-bottom:1px solid rgba(120,145,170,.18); }
.profile-info-grid b { word-break: break-word; }
@media (max-width: 560px) {
  .profile-info-grid > div { grid-template-columns: 1fr; gap:2px; }
}

/* V47 calendar/profile/month-position refinements */
.calendar-modal-list { display:grid; gap:10px; }
.calendar-modal-row {
  background: color-mix(in srgb, var(--event-bg, #eef3f8) 34%, #fff);
  border: 1px solid color-mix(in srgb, var(--event-bg, #eef3f8) 70%, #d8e1ea);
  border-left: 8px solid var(--event-bg, #d8e1ea);
  border-radius: 16px;
  padding: 14px 16px;
}
.calendar-modal-row .event-title { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:4px; }
.hr-checked-badge { font-weight:900; font-size:13px; box-shadow: 0 4px 12px rgba(26, 127, 55, .14); }
.event-color-badge { border:1px solid rgba(0,0,0,.06); }
.month-position-select { width: 100%; min-width: 135px; font-size: 12px; padding: 8px 10px; border-radius: 12px; }
.profile-info-grid { display:grid; gap:10px; }
.profile-info-grid > div { display:grid; grid-template-columns: 120px 1fr; gap:10px; padding:10px 0; border-bottom:1px solid var(--line); align-items:center; }
@media (max-width: 820px) {
  .profile-info-grid > div { grid-template-columns:1fr; gap:2px; padding:12px 0; }
  .calendar-modal-row { padding: 12px; border-radius: 14px; }
  .month-position-select { min-width: 120px; }
}

/* V48 users/admin: card layout instead of very wide table */
.users-page-v48 .card { overflow: visible; }
.admin-user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 14px;
}
.admin-user-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  padding: 14px;
  box-shadow: 0 8px 22px rgba(31,50,72,.04);
}
.admin-user-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.admin-user-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 900;
}
.admin-user-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-weight: 800;
}
.admin-user-form {
  display: grid;
  grid-template-columns: 88px 1fr 1fr;
  gap: 10px;
  align-items: end;
}
.admin-user-form label {
  font-size: 13px;
  gap: 5px;
}
.admin-user-form input,
.admin-user-form select {
  min-height: 40px;
  padding: 9px 10px;
  border-radius: 12px;
}
.admin-user-form label:nth-child(3),
.admin-user-form label:nth-child(4) { grid-column: span 1; }
.admin-user-form label:nth-child(12),
.admin-user-form label:nth-child(13),
.admin-user-form label:nth-child(14) { grid-column: span 1; }
.user-bottom-save { margin-top: 14px; justify-content: flex-end; }
@media (max-width: 1024px) {
  .admin-user-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .admin-user-form { grid-template-columns: 1fr; }
  .admin-user-head { align-items: flex-start; }
  .users-save-title { display: grid; }
  .users-save-title .primary-btn, .user-bottom-save .primary-btn { width: 100%; }
  .user-bottom-save { justify-content: stretch; }
}

/* V49: ผู้ใช้งานและสิทธิ์แบบเลือกทีละคน คล้ายสิทธิ์ตำแหน่งรายวัน */
.users-page-v49 .eligibility-staff-panel,
.users-page-v49 .eligibility-position-panel { min-width: 0; }
.users-page-v49 .admin-user-single-card { box-shadow: none; }
.users-page-v49 .add-user-details {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  background: #fff;
}
.users-page-v49 .add-user-details summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--blue-700);
}
.users-page-v49 .add-user-details .form-grid { margin-top: 12px; }
.users-page-v49 .admin-user-form {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}
@media (max-width: 1100px) {
  .users-page-v49 .admin-user-form { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}
@media (max-width: 820px) {
  .users-page-v49 .admin-user-form { grid-template-columns: 1fr; }
  .users-page-v49 .selected-staff-card { margin-bottom: 10px; }
}

/* V51: app-like centered messages for every save/error/confirm */
.app-alert, .app-confirm { text-align:center; padding: 8px 4px 2px; }
.app-alert-icon { width: 58px; height: 58px; border-radius: 22px; display:inline-grid; place-items:center; margin: 0 auto 12px; font-size: 30px; font-weight: 900; background:#dff4e7; color:#14804a; }
.app-alert.error .app-alert-icon { background:#ffe8ea; color:#c6364a; }
.app-alert-icon.warn { background:#fff4d7; color:#9b6a00; }
.app-alert h2, .app-confirm h2 { margin: 4px 0 8px; font-size: 24px; }
.app-alert p, .app-confirm p { margin: 0 auto 18px; color: var(--muted); line-height: 1.55; max-width: 460px; }
.dialog-textarea { width:100%; min-height:96px; border:1px solid var(--line); border-radius:16px; padding:12px 14px; font:inherit; resize:vertical; margin: 8px 0 14px; }
.app-alert .confirm-actions, .app-confirm .confirm-actions { justify-content:center; }
@media (max-width: 720px) {
  .app-alert h2, .app-confirm h2 { font-size: 21px; }
  .app-alert p, .app-confirm p { font-size: 15px; }
}


/* V56 mobile/sidebar/profile polish */
.nav-btn span:last-child { white-space: normal; line-height: 1.25; }
.sidebar { overflow-y: auto; overflow-x: hidden; }
.sidebar-foot { position: sticky; bottom: 0; background: linear-gradient(180deg, rgba(217,239,255,.75), #eef8ff 35%); padding-top: 10px; margin-top: 16px; }
.danger-ghost.full-btn, .full-btn { width: 100%; max-width: 100%; }
.profile-info-readable { gap: 12px; }
.profile-info-readable > div { grid-template-columns: 120px minmax(0,1fr); padding: 12px 0; line-height: 1.45; }
.profile-info-readable .muted { display:block; }
.profile-info-readable b { display:block; word-break: break-word; overflow-wrap:anywhere; }
.request-card { line-height: 1.55; }
@media (min-width: 821px) {
  .sidebar.collapsed { width: 86px; padding: 16px 10px; }
  .sidebar.collapsed .brand-text, .sidebar.collapsed .nav-section-title, .sidebar.collapsed .nav-btn span:last-child, .sidebar.collapsed .mini-profile span, .sidebar.collapsed .danger-ghost { display:none; }
  .sidebar.collapsed .nav-btn { justify-content:center; padding: 13px 8px; }
  .sidebar.collapsed .sidebar-head { justify-content:center; }
  body.sidebar-collapsed .app-shell { grid-template-columns: 86px minmax(0,1fr); }
}
@media (max-width: 820px) {
  .sidebar { width: 285px; max-width: 84vw; padding: 16px 14px; }
  .nav-btn { padding: 12px 12px; gap: 10px; font-size: 15px; }
  .sidebar-foot { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .profile-page-grid { grid-template-columns: 1fr !important; }
  .profile-card-readable { overflow:hidden; }
  .profile-info-readable > div { grid-template-columns: 88px minmax(0,1fr); gap: 8px; padding: 11px 0; align-items:start; }
}
@media (max-width: 560px) {
  .profile-info-readable > div { grid-template-columns: 1fr; gap: 4px; }
}

/* V57 layout polish */
.sidebar { width: 286px; }
.nav-btn { min-height: 46px; padding: 11px 13px; gap: 10px; }
.nav-btn span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.nav-section-title { gap: 8px; }
.sidebar-foot { margin-top: auto; position: sticky; bottom: 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
#logoutBtn { width: 100%; box-sizing: border-box; }
.profile-info-list { display: grid; gap: 0; margin: 12px 0 18px; }
.profile-info-list > div { display: grid; grid-template-columns: 130px minmax(0,1fr); gap: 14px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); line-height: 1.45; }
.profile-info-list span { color: var(--muted); }
.profile-info-list b { overflow-wrap: anywhere; word-break: break-word; }
.v57-profile-page .compact-form { gap: 12px; }
.v57-profile-page .two-cols { grid-template-columns: repeat(2, minmax(0,1fr)); }
.v57-request-card { padding: 16px; display: grid; gap: 8px; }
.request-head, .activity-row-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.v57-request-list { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.activity-list-card { max-height: calc(100vh - 150px); overflow: auto; }
.activity-card-list { display: grid; gap: 12px; }
.activity-row-card { border:1px solid var(--line); border-radius:18px; background:#fff; padding:14px; display:grid; gap:8px; }
.activity-row-detail { display:grid; grid-template-columns:92px minmax(0,1fr); gap:10px; }
.activity-row-detail span { color: var(--muted); }
.activity-row-detail b { overflow-wrap:anywhere; }
@media (min-width:821px) {
  .sidebar.collapsed { width: 84px; }
  body.sidebar-collapsed .app-shell { grid-template-columns: 84px minmax(0,1fr); }
}
@media (max-width: 1100px) {
  .activities-v57 { grid-template-columns: 1fr; }
  .activity-list-card { max-height: none; }
}
@media (max-width: 820px) {
  .sidebar { width: 292px; max-width: 86vw; display:flex; flex-direction:column; max-height: 100dvh; }
  .nav-btn { font-size: 15px; min-height: 44px; }
  .nav-btn span:last-child { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .profile-info-list > div { grid-template-columns: 96px minmax(0,1fr); gap: 10px; padding: 11px 0; }
  .v57-profile-page .two-cols { grid-template-columns: 1fr; }
  .v57-request-list { grid-template-columns: 1fr; }
  .activity-row-detail { grid-template-columns: 82px minmax(0,1fr); }
  .sidebar-foot { flex-shrink: 0; }
}
@media (max-width: 520px) {
  .profile-info-list > div { grid-template-columns: 1fr; gap: 3px; }
}

/* V59 hotfix: simple centered status modal */
.modal-status-icon {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px auto;
  font-size: 34px;
  font-weight: 900;
}
.modal-status-icon.error {
  background: #ffe8ea;
  color: #d9485f;
}
.modal-message {
  text-align: center;
  color: #6b7a90;
  font-size: 16px;
  line-height: 1.55;
  margin: 4px 0 10px;
}


/* V64: ลดความแน่นบนจอคอม โดยไม่กระทบ layout มือถือ */
@media (min-width: 821px) {
  html, body { font-size: 15px; }
  .app-view { grid-template-columns: 286px minmax(0, 1fr); }
  body.sidebar-collapsed .app-view { grid-template-columns: 84px minmax(0, 1fr); }
  .topbar { padding: 14px 22px; }
  .topbar h2 { font-size: 22px; line-height: 1.2; }
  .page-content { padding: 20px 22px; gap: 16px; }
  .card { padding: 16px; }
  .card h3 { font-size: 17px; }
  label { gap: 6px; }
  input, select, textarea { padding: 10px 12px; border-radius: 13px; }
  .primary-btn, .ghost-btn, .danger-ghost, .soft-btn { min-height: 40px; padding: 8px 14px; }
  .nav-btn { font-size: 15px; min-height: 42px; padding: 9px 12px; }
  .nav-section-title small { font-size: 11px; }
  .user-mini { font-size: 13px; padding: 10px; }
  th, td { padding: 10px 12px; }
  .profile-info-list > div { padding: 10px 0; }
}


/* V68 sidebar real hide fallback */
body.cnmi-sidebar-hidden .sidebar{display:none!important;width:0!important;min-width:0!important;max-width:0!important;padding:0!important;margin:0!important;border:0!important;overflow:hidden!important;}
body.cnmi-sidebar-hidden .app-view{display:grid!important;grid-template-columns:minmax(0,1fr)!important;}
body.cnmi-sidebar-hidden .main-panel{grid-column:1 / -1!important;width:100%!important;max-width:none!important;margin-left:0!important;}
body.cnmi-sidebar-hidden .topbar{left:0!important;}
body.cnmi-sidebar-hidden .page-content{max-width:none!important;}

/* V69 sidebar-only fix: keep drawer behavior clean and remove old collapsed strip */
body.cnmi-sidebar-hidden #sidebar.sidebar{display:none!important;width:0!important;min-width:0!important;max-width:0!important;padding:0!important;margin:0!important;border:0!important;overflow:hidden!important;}
body.cnmi-sidebar-hidden #appView.app-view{display:grid!important;grid-template-columns:minmax(0,1fr)!important;}
body.cnmi-sidebar-hidden .main-panel{grid-column:1 / -1!important;width:100%!important;max-width:none!important;margin-left:0!important;}
@media (max-width:820px){
  body:not(.sidebar-open):not(.cnmi-sidebar-hidden) #sidebar.sidebar:not(.open){transform:translateX(-105%)!important;pointer-events:none!important;}
  body.sidebar-open #sidebar.sidebar.open{transform:translateX(0)!important;pointer-events:auto!important;}
}

/* V70 sidebar-only: intermediate desktop/tablet must use drawer, not permanent column */
@media (max-width: 1180px) and (min-width: 821px) {
  #appView.app-view {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  #sidebar.sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    width: 292px !important;
    max-width: 86vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    z-index: 80 !important;
    transform: translateX(-105%) !important;
    transition: transform .22s ease !important;
    box-shadow: none !important;
  }
  body.sidebar-open #sidebar.sidebar {
    transform: translateX(0) !important;
    box-shadow: 18px 0 50px rgba(20,40,60,.25) !important;
  }
  #appView .main-panel {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(17,30,43,.28);
    z-index: 70;
  }
  body.cnmi-sidebar-hidden #sidebar.sidebar {
    display: none !important;
  }
}
/* v135 regression final fix: clickable tabs, compact schedule grid, Ch4 admin consistency */
.v135-schedule-tabs,
.mobile-schedule-tabs {
  position: relative;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
  pointer-events: auto !important;
}
.v135-schedule-tabs button,
.mobile-schedule-tabs button,
.v135-tab {
  cursor: pointer !important;
  position: relative;
  z-index: 60;
  pointer-events: auto !important;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 800;
}
.v135-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.loading-overlay, .busy-overlay, .screen-overlay, .route-guard-overlay { pointer-events: none !important; }

.v135-grid-wrap { max-width: 100%; overflow: auto; border-radius: 14px; }
.v135-schedule-grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; min-width: 1120px; font-size: 12px; }
.v135-schedule-grid th,
.v135-schedule-grid td { padding: 3px 4px !important; line-height: 1.15; min-width: 42px; height: 28px; vertical-align: middle; text-align: center; border-bottom: 1px solid #edf1f5; }
.v135-schedule-grid thead th { position: sticky; top: 0; z-index: 20; background: #f8fafc; font-weight: 900; }
.v135-schedule-grid .v135-sticky-name,
.v135-schedule-grid .v135-name-cell { position: sticky; left: 0; z-index: 25; min-width: 118px; width: 118px; max-width: 118px; box-shadow: 5px 0 10px rgba(15,35,52,.06); }
.v135-schedule-grid .v135-sticky-name { background: #fff; }
.v135-name-cell { background: var(--staff-bg) !important; color: var(--staff-fg) !important; text-align: left !important; }
.v135-name-cell button { all: unset; cursor: pointer; display: block; width: 100%; font-weight: 900; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v135-schedule-grid tr.zebra td:not(.v135-day-off-cell) { background: #fcfdff; }
.v135-day-off-col,
.v135-day-off-cell { background: #eef1f4 !important; }
.v135-cell-stack { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 20px; }
.v135-shift-pill { border: 0; border-radius: 999px; padding: 2px 6px; min-height: 18px; font-size: 11px; font-weight: 900; line-height: 1.1; background: var(--staff-bg); color: var(--staff-fg); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.v135-shift-pill:hover { filter: brightness(.96); transform: translateY(-1px); }
.v135-status { display: inline-block; border-radius: 999px; padding: 1px 5px; font-size: 10px; font-weight: 900; line-height: 1.2; background: #f3f4f6; color: #4b5563; border: 1px solid #d7dce2; white-space: nowrap; }
.v135-status.no-duty { background: #fff4e5; color: #9a5b00; border-color: #ffd79a; }
.v135-status.maternity { background: #f3e8ff; color: #6d28d9; border-color: #dbc2ff; }
.v135-status.leave { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

.v135-day-cards, .v135-person-list { display: grid; gap: 10px; }
.v135-day-card { border: 1px solid var(--line); border-radius: 16px; padding: 10px; background: #fff; }
.v135-day-card.dayoff { background: #f4f6f8; }
.v135-day-head, .v135-day-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.v135-day-head { padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.v135-day-line { padding: 4px 0; }
.v135-person-list { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.v135-person-card { text-align: left; border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; background: var(--staff-bg); color: var(--staff-fg); cursor: pointer; display: grid; gap: 3px; }
.v135-person-card small { opacity: .85; }

.v135-roster-admin { table-layout: fixed; min-width: 1080px; }
.v135-roster-admin th,
.v135-roster-admin td { padding: 4px 5px !important; line-height: 1.15; }
.v135-roster-admin .roster-slot { padding: 5px !important; min-height: 54px; }
.v135-roster-admin .slot-meta { font-size: 10px; }
.v135-roster-admin-wrap { max-height: 74vh; }
.v135-admin-dayoff-row td { background: #f5f6f8; }

@media (max-width: 820px) {
  .v135-schedule-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .v135-schedule-grid { min-width: 980px; font-size: 11px; }
  .v135-schedule-grid th, .v135-schedule-grid td { min-width: 38px; padding: 2px 3px !important; }
  .v135-shift-pill { font-size: 10px; padding: 2px 5px; }
}

@media print {
  .v135-schedule-tabs, .no-print, .trade-panel, .sidebar, .topbar { display: none !important; }
  .v135-grid-wrap { overflow: visible !important; border: 0 !important; }
  .v135-schedule-grid { min-width: 0 !important; width: 100% !important; font-size: 7px !important; table-layout: fixed !important; }
  .v135-schedule-grid th, .v135-schedule-grid td { padding: 1px 2px !important; height: auto !important; min-width: 0 !important; word-break: break-word; white-space: normal; }
  .v135-schedule-grid .v135-sticky-name, .v135-schedule-grid .v135-name-cell { position: static !important; width: 64px !important; min-width: 64px !important; max-width: 64px !important; box-shadow: none !important; }
  .v135-shift-pill, .v135-status, .v135-name-cell, .v135-day-off-cell, .v135-day-off-col { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* v136 final UI consistency: compact sticky tabs, compact admin grid, stable visual mapping */
.v136-schedule-page { position: relative; }
.v136-schedule-tabs {
  position: sticky;
  top: 0;
  z-index: 120;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 0;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #e8edf3;
  pointer-events: auto !important;
}
.v136-tab {
  border: 1px solid #dbe4ee;
  background: #fff;
  color: #25364a;
  border-radius: 12px;
  min-height: 36px;
  padding: 6px 8px;
  font-weight: 900;
  cursor: pointer !important;
  pointer-events: auto !important;
  position: relative;
  z-index: 121;
  line-height: 1.15;
}
.v136-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.loading-overlay, .busy-overlay, .screen-overlay, .route-guard-overlay { pointer-events: none !important; }

.v136-grid-wrap { max-width: 100%; overflow: auto; border: 1px solid #e7edf4; border-radius: 14px; }
.v136-schedule-grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; min-width: 1080px; width: max-content; font-size: 11px; background: #fff; }
.v136-schedule-grid th,
.v136-schedule-grid td { padding: 2px 3px !important; line-height: 1.1 !important; min-width: 34px; max-width: 46px; height: 24px !important; vertical-align: middle; text-align: center; border-bottom: 1px solid #edf2f7; border-right: 1px solid #f1f4f7; }
.v136-schedule-grid thead th { position: sticky; top: 0; z-index: 30; background: #f8fafc; font-weight: 900; }
.v136-schedule-grid .v136-sticky-name,
.v136-schedule-grid .v136-name-cell { position: sticky; left: 0; z-index: 40; min-width: 112px !important; width: 112px !important; max-width: 112px !important; box-shadow: 5px 0 10px rgba(15,35,52,.06); }
.v136-schedule-grid .v136-sticky-name { background: #fff !important; }
.v136-name-cell { background: var(--staff-bg) !important; color: var(--staff-fg) !important; text-align: left !important; }
.v136-name-cell button { all: unset; cursor: pointer; display: block; width: 100%; font-weight: 900; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v136-schedule-grid tr.zebra td:not(.v136-dayoff-cell) { background: #fcfdff; }
.v136-dayoff-col, .v136-dayoff-cell { background: #eceff3 !important; }
.v136-cell-stack { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 18px; }
.v136-shift-pill { border: 0; border-radius: 999px; padding: 1px 5px; min-height: 16px; font-size: 10px; font-weight: 900; line-height: 1.1; background: var(--staff-bg); color: var(--staff-fg); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); white-space: nowrap; }
.v136-shift-pill:hover { filter: brightness(.96); transform: translateY(-1px); }
.v136-status { display: inline-block; border-radius: 999px; padding: 1px 4px; font-size: 9px; font-weight: 900; line-height: 1.15; background: #f3f4f6; color: #4b5563; border: 1px solid #d7dce2; white-space: nowrap; }
.v136-status.no-duty { background: #fff4e5; color: #9a5b00; border-color: #ffd79a; }
.v136-status.maternity { background: #f3e8ff; color: #6d28d9; border-color: #dbc2ff; }
.v136-status.leave { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

.v136-calendar-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.v136-day-card { border: 1px solid #e1e8f0; border-radius: 16px; padding: 9px; background: #fff; }
.v136-day-card.dayoff { background: #f4f6f8; }
.v136-day-head, .v136-day-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.v136-day-head { padding-bottom: 5px; margin-bottom: 5px; border-bottom: 1px solid #e8edf3; }
.v136-day-line { padding: 3px 0; }
.v136-person-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.v136-person-card { text-align: left; border: 1px solid #dbe4ee; border-radius: 16px; padding: 10px 12px; background: var(--staff-bg); color: var(--staff-fg); cursor: pointer; display: grid; gap: 2px; }
.v136-person-card small { opacity: .85; }
.v136-balance-table th, .v136-balance-table td { padding: 7px 8px !important; }
.v136-balance-status { display: inline-block; border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 900; }
.v136-balance-status.ok { background:#dcfce7; color:#166534; }
.v136-balance-status.warn { background:#fef3c7; color:#92400e; }
.v136-balance-status.over { background:#fee2e2; color:#991b1b; }
.v136-balance-status.exempt { background:#ede9fe; color:#5b21b6; }

.v136-roster-admin-wrap { max-height: 74vh; max-width: 100%; overflow: auto; border-radius: 14px; }
.v136-roster-admin { table-layout: fixed !important; min-width: 1080px; width: max-content; font-size: 12px; }
.v136-roster-admin th,
.v136-roster-admin td { padding: 3px 4px !important; line-height: 1.1 !important; vertical-align: middle; }
.v136-roster-admin .v136-admin-date-col,
.v136-roster-admin .v136-admin-date { width: 100px !important; min-width: 100px !important; max-width: 100px !important; }
.v136-roster-admin .roster-slot { padding: 4px !important; min-height: 44px !important; gap: 3px !important; }
.v136-roster-admin .slot-meta { display: none !important; }
.v136-roster-admin .assigned-name small,
.v136-roster-admin .staff-color-pill small { display: none !important; }
.v136-roster-admin select { padding: 5px 6px !important; min-height: 30px !important; font-size: 12px !important; }
.v136-roster-admin .actions { gap: 3px !important; }
.v136-roster-admin .tiny-btn { min-height: 24px !important; padding: 3px 6px !important; font-size: 11px !important; }
.v136-admin-dayoff-row td { background: #f4f6f8; }

@media (max-width: 820px) {
  .v136-schedule-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); top: 0; }
  .v136-tab { font-size: 12px; }
  .v136-schedule-grid { min-width: 960px; font-size: 10px; }
  .v136-schedule-grid th, .v136-schedule-grid td { padding: 2px !important; }
  .v136-shift-pill { font-size: 9px; padding: 1px 4px; }
  .v136-calendar-cards { grid-template-columns: 1fr; }
}
@media print {
  .v136-schedule-tabs, .v136-toolbar, .no-print, .trade-panel, .sidebar, .topbar { display: none !important; }
  .v136-grid-wrap { overflow: visible !important; border: 0 !important; }
  .v136-schedule-grid { min-width: 0 !important; width: 100% !important; font-size: 7px !important; table-layout: fixed !important; }
  .v136-schedule-grid th, .v136-schedule-grid td { padding: 1px 2px !important; height: auto !important; min-width: 0 !important; max-width: none !important; word-break: break-word; white-space: normal; }
  .v136-schedule-grid .v136-sticky-name, .v136-schedule-grid .v136-name-cell { position: static !important; width: 64px !important; min-width: 64px !important; max-width: 64px !important; box-shadow: none !important; }
  .v136-shift-pill, .v136-status, .v136-name-cell, .v136-dayoff-cell, .v136-dayoff-col { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}


/* v141: Force-visible Admin Long-term Leave UI */
.long-leave-field select {
  border-color: #f2b84b;
  background: #fffaf0;
}
.long-leave-admin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px dashed #f2b84b;
  border-radius: 14px;
  background: #fffaf0;
}
.long-leave-admin-actions .warning,
.v141-long-leave-actions .warning {
  border-color: #f2b84b;
  background: #fff4d6;
  color: #7a4b00;
}
.v141-long-leave-inline-note {
  display:block;
  margin-top:4px;
  color:#8a5a00;
  font-size:12px;
}

/* V150 clean components: schedule / OT / month position fixes */
.clean-schedule-tabs{
  position: sticky;
  top: 0;
  z-index: 40;
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
  background:#fff;
  padding:8px 0;
  margin:8px 0 12px;
  border-bottom:1px solid #e5e7eb;
}
.clean-calendar-cards{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(220px,1fr));
  gap:10px;
}
.clean-day-card,.clean-person-card{
  border:1px solid #e5e7eb;
  border-radius:14px;
  background:#fff;
  padding:10px;
}
.clean-day-card.is-offday{background:#f8fafc;}
.clean-day-head,.clean-day-line,.clean-person-duty{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
.clean-day-head{margin-bottom:8px;}
.clean-day-line,.clean-person-duty{
  padding:5px 0;
  border-top:1px dashed #e5e7eb;
}
.clean-person-list{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(240px,1fr));
  gap:10px;
}
.clean-person-card{
  background:var(--staff-bg,#fff);
  color:var(--staff-fg,#111827);
}
.clean-person-head{
  width:100%;
  border:0;
  background:transparent;
  color:inherit;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:0 0 8px;
  cursor:pointer;
}
.clean-grid-wrap{overflow:auto;}
.clean-schedule-grid,.clean-balance-table{
  border-collapse:collapse;
  width:max-content;
  min-width:100%;
  table-layout:fixed;
}
.clean-schedule-grid th,.clean-schedule-grid td,.clean-balance-table th,.clean-balance-table td{
  border:1px solid #e5e7eb;
  padding:4px 6px;
  vertical-align:top;
  font-size:12px;
}
.clean-schedule-grid thead th{
  position:sticky;
  top:0;
  z-index:15;
  background:#f8fafc;
}
.clean-sticky-col{
  position:sticky!important;
  left:0;
  z-index:20!important;
}
.clean-staff-cell{
  background:var(--staff-bg,#fff)!important;
  color:var(--staff-fg,#111827)!important;
  min-width:110px;
  max-width:130px;
}
.clean-staff-cell button{
  all:unset;
  cursor:pointer;
  font-weight:800;
}
.offday-col{background:#f1f5f9!important;}
.clean-cell-stack{
  min-height:22px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:2px;
}
.clean-shift-pill{
  border:0;
  border-radius:999px;
  background:#dbeafe;
  color:#1e3a8a;
  font-weight:800;
  font-size:11px;
  line-height:1.1;
  padding:3px 7px;
  cursor:pointer;
}
.mini-status{
  display:inline-block;
  border:1px solid #fdba74;
  background:#fff7ed;
  color:#9a3412;
  border-radius:999px;
  padding:1px 5px;
  font-size:10px;
  font-weight:800;
}
.clean-balance-dashboard .notice{margin-bottom:10px;}
.ot-approval-filter{
  display:flex;
  flex-wrap:wrap;
  align-items:end;
  gap:10px;
  margin:8px 0 12px;
}
.ot-approval-filter label{
  display:flex;
  flex-direction:column;
  gap:4px;
  margin:0;
  min-width:180px;
}
.ot-approval-filter input,.ot-approval-filter select{width:100%;}
.month-position-matrix .holiday-cell,.month-position-matrix .weekend-cell{background:#f1f5f9!important;color:#334155;font-weight:800;}
.month-position-matrix .no-position-day span{display:inline-block;border-radius:999px;background:#e5e7eb;padding:4px 8px;}
@media(max-width:700px){
  .ot-approval-filter{align-items:stretch;}
  .ot-approval-filter label{width:100%;min-width:0;}
  .clean-schedule-grid th,.clean-schedule-grid td{font-size:10px;padding:3px 4px;}
  .clean-staff-cell{min-width:96px;}
}

/* V151 clean requirement fixes */
.clean-balance-table th:first-child,
.clean-balance-table td:first-child{
  position:sticky;
  left:0;
  z-index:12;
  background:#fff;
  box-shadow:1px 0 0 #e5e7eb;
}
.clean-balance-table thead th:first-child{z-index:18;background:#f8fafc;}
.clean-grid-wrap{max-width:100%;}
.clean-schedule-grid{
  width:max-content;
  min-width:max-content;
  table-layout:fixed;
}
.clean-schedule-grid th:not(.clean-sticky-col),
.clean-schedule-grid td{width:54px;min-width:54px;max-width:54px;}
.clean-schedule-grid .clean-sticky-col{width:auto;min-width:92px;max-width:none;white-space:nowrap;}
.clean-staff-cell button{white-space:nowrap;}
.clean-shift-pill{
  background:var(--staff-bg,#dbeafe);
  color:var(--staff-fg,#1e3a8a);
  width:100%;
  max-width:48px;
  overflow:hidden;
}
.person-filter-mobile{display:none;margin-bottom:10px;}
.clean-person-mobile-result{display:none;}
.person-filter-mobile label{display:flex;flex-direction:column;gap:6px;}
.person-filter-mobile select{width:100%;}
.ot-approval-filter{
  display:flex;
  flex-wrap:wrap;
  align-items:flex-end;
  gap:10px;
}
.ot-approval-filter label{flex:1 1 180px;}
.ot-approval-filter label:first-child{flex:2 1 260px;}
@media(max-width:700px){
  .person-filter-mobile,.clean-person-mobile-result{display:block;}
  .clean-person-list{display:none;}
  .clean-schedule-grid th:not(.clean-sticky-col),
  .clean-schedule-grid td{width:48px;min-width:48px;max-width:48px;}
  .clean-shift-pill{max-width:42px;padding:3px 4px;}
}

/* V152 SRS clean fixes: roster-only staff, leave colors, compact grid, full sidebar hide */
body.cnmi-sidebar-hidden #sidebar.sidebar{
  display:none!important;
  width:0!important;
  min-width:0!important;
  max-width:0!important;
  padding:0!important;
  margin:0!important;
  border:0!important;
  overflow:hidden!important;
}
body.cnmi-sidebar-hidden #appView.app-view{
  grid-template-columns:minmax(0,1fr)!important;
}
body.cnmi-sidebar-hidden .main-panel{
  grid-column:1 / -1!important;
  width:100%!important;
  max-width:none!important;
  margin-left:0!important;
}
body.cnmi-sidebar-hidden .page-content{max-width:none!important;}

.clean-grid-wrap,.clean-balance-dashboard .table-wrap{overflow:auto;max-width:100%;}
.clean-schedule-grid{
  width:max-content!important;
  min-width:max-content!important;
  table-layout:fixed!important;
}
.clean-schedule-grid th:not(.clean-sticky-col),
.clean-schedule-grid td{
  width:52px!important;
  min-width:52px!important;
  max-width:52px!important;
  padding:3px 4px!important;
}
.clean-schedule-grid .clean-sticky-col{
  width:auto!important;
  min-width:max-content!important;
  max-width:none!important;
  white-space:nowrap!important;
  left:0!important;
}
.clean-staff-cell button{white-space:nowrap!important;overflow:visible!important;text-overflow:clip!important;}
.clean-shift-pill{
  background:var(--staff-bg,#dbeafe)!important;
  color:var(--staff-fg,#1e3a8a)!important;
  width:auto!important;
  min-width:38px;
  max-width:none!important;
  white-space:nowrap;
}
.clean-balance-table th:first-child,
.clean-balance-table td:first-child{
  position:sticky!important;
  left:0!important;
  z-index:12!important;
  background:#fff!important;
  box-shadow:1px 0 0 #e5e7eb;
  white-space:nowrap;
}
.clean-balance-table thead th:first-child{z-index:18!important;background:#f8fafc!important;}

.mini-status.leave-personal,.matrix-cell.leave-personal{background:#ede9fe!important;color:#5b21b6!important;border-color:#c4b5fd!important;}
.mini-status.leave-sick,.matrix-cell.leave-sick{background:#fef3c7!important;color:#92400e!important;border-color:#fcd34d!important;}
.mini-status.leave-vacation,.matrix-cell.leave-vacation{background:#dcfce7!important;color:#166534!important;border-color:#86efac!important;}
.mini-status.leave-no-duty,.matrix-cell.leave-no-duty{background:#e5e7eb!important;color:#374151!important;border-color:#cbd5e1!important;}
.mini-status.leave-other,.matrix-cell.leave-other{background:#e0f2fe!important;color:#075985!important;border-color:#7dd3fc!important;}
.mini-status{font-weight:900;white-space:nowrap;}
.month-position-matrix .holiday-cell,
.month-position-matrix .weekend-cell{
  background:#f1f5f9!important;
  color:#334155!important;
  font-weight:900!important;
  pointer-events:none;
}

@media(max-width:700px){
  .person-filter-mobile,.clean-person-mobile-result{display:block!important;}
  .clean-person-list{display:none!important;}
  .clean-schedule-grid th:not(.clean-sticky-col),
  .clean-schedule-grid td{width:46px!important;min-width:46px!important;max-width:46px!important;}
}

/* V153 targeted UI fixes */
.mini-status.leave-maternity,
.matrix-cell.leave-maternity,
.clean-schedule-grid td.leave-maternity{
  background:#fce7f3!important;
  color:#9d174d!important;
  border-color:#f9a8d4!important;
}
.clean-schedule-grid td.leave-personal{background:#ede9fe!important;}
.clean-schedule-grid td.leave-sick{background:#fef3c7!important;}
.clean-schedule-grid td.leave-vacation{background:#dcfce7!important;}
.clean-schedule-grid td.leave-no-duty{background:#e5e7eb!important;}
.clean-schedule-grid td.leave-other{background:#e0f2fe!important;}
.clean-schedule-grid .clean-cell-stack{gap:2px!important;align-items:center!important;justify-content:center!important;}
.clean-schedule-grid .mini-status{font-size:9px!important;line-height:1.05!important;padding:2px 4px!important;white-space:nowrap!important;}
.month-position-matrix .matrix-cell.leave-maternity{background:#fce7f3!important;color:#9d174d!important;}
.month-position-matrix .matrix-cell.needs-review-cell:empty{background:#fff!important;}
.v153-position-matrix .matrix-legend .leave::after{content:'';}
@media (min-width:821px){
  body.cnmi-sidebar-hidden #appView.app-view{grid-template-columns:minmax(0,1fr)!important;width:100%!important;}
  body.cnmi-sidebar-hidden #sidebar.sidebar{display:none!important;visibility:hidden!important;position:absolute!important;left:-9999px!important;}
  body.cnmi-sidebar-hidden .main-panel{grid-column:1 / -1!important;width:100%!important;max-width:100%!important;}
  body.cnmi-sidebar-hidden .topbar,
  body.cnmi-sidebar-hidden .page-content{width:100%!important;max-width:none!important;}
  body:not(.cnmi-sidebar-hidden) #appView.app-view{grid-template-columns:286px minmax(0,1fr)!important;}
  body:not(.cnmi-sidebar-hidden) #sidebar.sidebar{display:flex!important;position:sticky!important;}
}

/* V158 grouped averages + compact monthly-position staff column + missing roles tracker */
.grouped-balance-dashboard{
  display:grid;
  gap:14px;
}
.balance-group-section{
  border:1px solid #e5e7eb;
  border-radius:18px;
  padding:12px;
  background:#fff;
}
.balance-group-title{
  align-items:center;
  gap:10px;
  margin-bottom:8px;
}
.v158-position-matrix .staff-color-cell{
  padding:5px 8px!important;
  min-width:112px!important;
  max-width:132px!important;
  line-height:1.1!important;
}
.v158-position-matrix .compact-staff-summary{
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:2px;
  min-height:0;
}
.v158-position-matrix .compact-staff-summary b{
  font-size:12px;
  line-height:1.05;
  white-space:nowrap;
}
.v158-position-matrix .compact-staff-summary span{
  margin-top:0;
  padding:0;
  background:transparent;
  font-size:10px;
  line-height:1.05;
  text-decoration:underline;
  opacity:.92;
}
.v158-position-matrix .compact-staff-summary:hover span{
  background:transparent;
  opacity:1;
}
.v158-position-matrix .missing-role-row th{
  position:sticky;
  top:0;
  z-index:4;
  border-top:0;
  vertical-align:top;
}
.v158-position-matrix .missing-role-head{
  background:#f8fafc!important;
  color:#64748b;
  font-size:11px;
  font-weight:900;
}
.v158-position-matrix .missing-role-cell{
  min-width:108px;
  max-width:128px;
  padding:4px 5px!important;
  font-size:10px;
  line-height:1.15;
  white-space:normal;
}
.v158-position-matrix .missing-role-cell span{
  display:block;
  margin:2px 0;
  padding:2px 5px;
  border-radius:999px;
  background:#fff7ed;
  color:#9a3412;
  border:1px solid #fed7aa;
  font-weight:900;
  white-space:nowrap;
}
.v158-position-matrix .missing-role-cell.complete{
  background:#ecfdf5;
  color:#047857;
  font-weight:900;
}
.v158-position-matrix .missing-role-cell.no-position-day{
  background:#f1f5f9;
  color:#64748b;
  font-weight:900;
}
@media(max-width:720px){
  .v158-position-matrix .staff-color-cell{min-width:96px!important;max-width:112px!important;}
  .v158-position-matrix .missing-role-cell{min-width:92px;max-width:106px;font-size:9px;}
}

/* V159: compact monthly-position staff columns, roster swap DnD, leave filters */
.leave-filter-bar{
  display:flex;
  gap:10px;
  align-items:flex-end;
  flex-wrap:wrap;
  margin:0 0 12px;
  padding:10px;
  border:1px solid var(--line);
  border-radius:16px;
  background:#f8fbff;
}
.leave-filter-bar label{flex:1 1 160px;min-width:150px;}
.leave-filter-bar select{width:100%;}
.roster-slot.has-staff[draggable="true"]{cursor:grab;}
.roster-slot.has-staff[draggable="true"]:active{cursor:grabbing;}
.roster-slot.dragging{opacity:.62;border-style:solid;}
.roster-slot.drag-over{outline:2px solid rgba(128,202,255,.65);outline-offset:2px;}
.v159-position-matrix{--month-staff-col-width:112px;--month-summary-col-width:72px;}
.v159-position-matrix .month-position-matrix table{min-width:1580px;}
.v159-position-matrix .staff-col{
  min-width:var(--month-staff-col-width)!important;
  max-width:var(--month-staff-col-width)!important;
  width:var(--month-staff-col-width)!important;
}
.v159-position-matrix .summary-col{
  position:sticky;
  left:var(--month-staff-col-width);
  z-index:4;
  min-width:var(--month-summary-col-width)!important;
  max-width:var(--month-summary-col-width)!important;
  width:var(--month-summary-col-width)!important;
  box-shadow:4px 0 10px rgba(31,50,72,.06);
}
.v159-position-matrix thead .summary-col{z-index:6;background:#f6f9fc;}
.v159-position-matrix tbody .summary-col{background:#ffffff;}
.v159-position-matrix .staff-color-cell{
  padding:4px 7px!important;
  line-height:1.05!important;
}
.v159-position-matrix .matrix-staff-name{
  display:flex;
  align-items:center;
  gap:6px;
  min-height:24px;
  white-space:nowrap;
}
.v159-position-matrix .matrix-staff-name b{font-size:12px;line-height:1;}
.v159-position-matrix .matrix-staff-name small{font-size:9px;line-height:1;opacity:.88;}
.v159-position-matrix .summary-action-cell{padding:4px 6px!important;text-align:center!important;}
.v159-position-matrix .summary-action-cell .staff-summary-trigger{
  width:auto;
  min-width:54px;
  padding:4px 8px;
  border-radius:999px;
  background:#eff6ff;
  color:#1d4e89;
  border:1px solid #bfdbfe;
  font-size:10px;
  text-decoration:none;
}
.v159-position-matrix .summary-action-cell .staff-summary-trigger:hover{background:#dbeafe;}
.v159-position-matrix .matrix-cell{padding-top:5px!important;padding-bottom:5px!important;}
.v159-position-matrix .cell-note{display:none!important;}
@media(max-width:720px){
  .leave-filter-bar{display:grid;grid-template-columns:1fr;}
  .leave-filter-bar label{min-width:0;width:100%;}
  .v159-position-matrix{--month-staff-col-width:96px;--month-summary-col-width:62px;}
  .v159-position-matrix .matrix-staff-name{gap:4px;}
  .v159-position-matrix .summary-action-cell .staff-summary-trigger{min-width:48px;padding:3px 6px;font-size:9px;}
}

/* V160 targeted responsive UI patch */
.calendar-card-grid .calendar-card-cell{appearance:none;border:1px solid var(--line);text-align:left;cursor:pointer;transition:.15s;}
.calendar-card-grid .calendar-card-cell:hover{transform:translateY(-1px);box-shadow:0 10px 24px rgba(31,50,72,.10);}
.calendar-card-grid .fake-btn{pointer-events:none;}
@media(max-width:820px){
  .calendar-card-grid{display:grid;grid-template-columns:repeat(7,minmax(96px,1fr));overflow-x:auto;padding-bottom:8px;}
  .calendar-card-grid .calendar-dayname{position:sticky;top:0;z-index:2;min-width:96px;}
  .calendar-card-grid .calendar-card-cell{min-width:96px;min-height:118px;padding:8px;}
  .calendar-card-grid .event-pill{font-size:10px;padding:4px 6px;}
}
.clean-balance-dashboard .table-wrap{overflow:auto!important;}
.clean-balance-table th:first-child,.clean-balance-table td:first-child{position:sticky!important;left:0!important;z-index:20!important;background:#fff!important;box-shadow:2px 0 0 #e5e7eb;}
.clean-balance-table thead th:first-child{z-index:25!important;background:#f8fafc!important;}
.v160-schedule-grid .clean-summary-head,.v160-schedule-grid .clean-summary-cell{position:sticky!important;left:112px!important;z-index:19!important;background:#fff!important;min-width:70px!important;width:70px!important;max-width:70px!important;box-shadow:2px 0 0 #e5e7eb;}
.v160-schedule-grid thead .clean-summary-head{z-index:24!important;background:#f8fafc!important;}
.v160-schedule-grid .clean-staff-head,.v160-schedule-grid .clean-staff-cell{left:0!important;min-width:112px!important;width:112px!important;max-width:112px!important;}
.v160-schedule-grid .clean-staff-cell{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.v160-position-matrix .staff-col{left:0!important;}
.v160-position-matrix .summary-col{left:var(--month-staff-col-width)!important;}
@media(max-width:700px){
  .clean-balance-table th:first-child,.clean-balance-table td:first-child{min-width:110px!important;max-width:130px!important;}
  .v160-schedule-grid .clean-staff-head,.v160-schedule-grid .clean-staff-cell{min-width:96px!important;width:96px!important;max-width:96px!important;}
  .v160-schedule-grid .clean-summary-head,.v160-schedule-grid .clean-summary-cell{left:96px!important;min-width:62px!important;width:62px!important;max-width:62px!important;}
}

/* V161 force first-login setup */
.force-setup-shell{max-width:760px;margin:24px auto;}
.force-setup-card{border:1px solid rgba(59,130,246,.22);box-shadow:0 16px 45px rgba(59,130,246,.12);}
.compact-info{margin:12px 0 16px;}
.nav-force-note{padding:12px;margin:8px;border-radius:14px;background:#fff7ed;color:#9a3412;font-size:.9rem;font-weight:700;line-height:1.4;}

/* V162: single login form + safer table rendering */
.auth-tabs.hidden,
#setupPasswordForm.hidden { display:none!important; }
.login-helper-text{
  margin-top:10px;
  padding:10px 12px;
  border:1px solid #bfdbfe;
  border-radius:14px;
  background:#eff6ff;
  color:#1e3a8a;
  line-height:1.55;
  font-weight:600;
}
.v162-account-settings .profile-info-list b{word-break:break-word;}
.v162-position-matrix .month-position-matrix table{table-layout:auto;}
.v162-position-matrix .summary-col{
  min-width:72px!important;
  max-width:72px!important;
  width:72px!important;
  background:#fff;
  box-shadow:2px 0 0 #e5e7eb;
}
.v162-position-matrix thead .summary-col{background:#f6f9fc;z-index:4;}
.v162-position-matrix .staff-col{left:0!important;}
.v162-position-matrix .matrix-cell .cell-note{display:none!important;}
.v162-position-matrix .matrix-cell{contain:layout paint;}
.v162-daily-position-table table{min-width:920px;}
.error-notice{border-color:#fecaca;background:#fef2f2;color:#991b1b;}
@media(max-width:720px){
  .v162-position-matrix .summary-col{min-width:62px!important;max-width:62px!important;width:62px!important;}
  .login-helper-text{font-size:.92rem;}
}
.v162-position-matrix .summary-col{position:static!important;left:auto!important;}
.v162-schedule-grid .clean-summary-head,
.v162-schedule-grid .clean-summary-cell{position:static!important;left:auto!important;min-width:70px!important;width:70px!important;max-width:70px!important;background:#fff!important;box-shadow:2px 0 0 #e5e7eb;}
.v162-schedule-grid thead .clean-summary-head{background:#f8fafc!important;}
.v162-schedule-grid .clean-staff-head,
.v162-schedule-grid .clean-staff-cell{left:0!important;}

/* V163 Account/Profile merge + OT attendance form */
.v163-profile-page .account-settings-card,
.v163-profile-page .profile-card-readable { min-width: 0; }
.v163-ot-page .attendance-form { margin-top: 10px; }
.v163-ot-page .admin-checkin-fields {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(128, 202, 255, 0.10);
  border-radius: 14px;
  padding: 10px;
}
.v163-ot-page .admin-checkin-fields label { min-width: 0; }
@media (max-width: 820px) {
  .v163-ot-page .form-grid.two-cols,
  .v163-ot-page .admin-checkin-fields { grid-template-columns: 1fr; }
}


/* V165 Responsive fixes: OT attendance form + profile/account spacing */
.v165-ot-page .ot-card { min-width: 0; }
.v165-attendance-form {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 16px !important;
  align-items: stretch !important;
}
.v165-checkin-fields,
.v165-admin-checkin-fields {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
  gap: 14px !important;
  width: 100%;
  min-width: 0;
}
.v165-admin-checkin-fields {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(128, 202, 255, 0.10);
  border-radius: 16px;
  padding: 14px;
}
.v165-attendance-form label,
.v165-ot-extra-form label,
.v165-account-form label,
.v165-profile-change-form label {
  display: grid;
  gap: 8px;
  min-width: 0;
  align-content: start;
  font-weight: 800;
}
.v165-attendance-form input,
.v165-attendance-form select,
.v165-ot-extra-form input,
.v165-ot-extra-form select,
.v165-account-form input,
.v165-profile-change-form input,
.v165-profile-change-form select,
.v165-profile-change-form textarea {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.v165-attendance-form .primary-btn { justify-self: start; min-width: min(100%, 280px); }
.v165-profile-page { align-items: start; }
.v165-profile-page .card { padding: 22px; }
.v165-profile-info { gap: 2px; margin-top: 16px; }
.v165-profile-info > div {
  grid-template-columns: minmax(130px, 170px) minmax(0, 1fr);
  gap: 18px;
  padding: 13px 0;
}
.v165-account-settings-card .section-title,
.v165-request-card .section-title { margin-bottom: 18px; }
.v165-account-form,
.v165-profile-change-form {
  grid-template-columns: 1fr !important;
  gap: 16px !important;
  align-items: stretch !important;
}
.v165-account-form .hint { margin-top: 0; line-height: 1.45; }
.v165-profile-change-form .two-cols {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
  gap: 14px !important;
}
@media (min-width: 980px) {
  .v165-account-form { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .v165-account-form label:first-child { grid-column: 1 / -1; }
  .v165-account-form .wide { grid-column: 1 / -1; justify-self: start; min-width: 280px; }
}
@media (max-width: 820px) {
  .v165-checkin-fields,
  .v165-admin-checkin-fields { grid-template-columns: 1fr !important; }
  .v165-attendance-form .primary-btn { width: 100%; }
  .v165-profile-page .card { padding: 18px; }
  .v165-profile-info > div { grid-template-columns: 105px minmax(0, 1fr); gap: 12px; }
}
@media (max-width: 520px) {
  .v165-profile-info > div { grid-template-columns: 1fr; gap: 5px; }
}


/* V166 Login input height + show/hide password */
input, select {
  min-height: 46px;
  line-height: 1.5;
}
textarea {
  line-height: 1.5;
}
.auth-card label {
  gap: 8px;
}
.auth-card input {
  min-height: 52px;
  padding-top: 14px;
  padding-bottom: 14px;
  line-height: 1.5;
}
.password-field {
  position: relative;
  display: block;
  width: 100%;
}
.password-field input {
  width: 100%;
  padding-right: 50px !important;
  box-sizing: border-box;
}
.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  background: #eef6ff;
  color: #1e3a8a;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  box-shadow: none;
}
.password-toggle:hover {
  filter: brightness(.97);
}
.admin-user-head .user-password-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.admin-user-head .danger-soft-btn {
  border-color: #fecaca;
  background: #fff5f5;
  color: #991b1b;
}
@media (max-width: 640px) {
  .admin-user-head { align-items: stretch; }
  .admin-user-head .user-password-actions { justify-content: flex-start; }
}

/* V167 Global Role Switcher */
.view-as-wrap { position: relative; }
.view-as-toggle { width: 100%; border: 0; background: rgba(255,255,255,.72); border-radius: 18px; padding: 10px; display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 8px; align-items: center; text-align: left; color: var(--sidebar-ink); cursor: pointer; }
.view-as-toggle:hover { background: #fff; box-shadow: 0 8px 20px rgba(31,72,110,.10); }
.view-as-user { min-width: 0; display: grid; gap: 3px; font-weight: 900; }
.view-as-user small { color: rgba(23,53,77,.68); font-weight: 800; line-height: 1.25; }
.view-as-badge { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 900; white-space: nowrap; }
.view-as-badge.staff { background: #e5f7ed; color: #19774b; }
.view-as-badge.admin { background: #ffe9ee; color: #b3354c; }
.view-as-chevron { color: rgba(23,53,77,.62); font-weight: 900; }
.view-as-menu { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 120; display: grid; gap: 6px; padding: 8px; border: 1px solid rgba(23,53,77,.12); border-radius: 18px; background: rgba(255,255,255,.98); box-shadow: 0 18px 50px rgba(20,40,60,.20); }
.view-as-menu.hidden { display: none !important; }
.view-as-option { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 10px; display: grid; gap: 3px; text-align: left; color: var(--ink); cursor: pointer; }
.view-as-option:hover { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(128,202,255,.16); }
.view-as-option.active { background: var(--primary-soft); border-color: var(--primary); }
.view-as-option small { color: var(--muted); font-weight: 700; line-height: 1.25; }
@media (max-width: 820px) {
  .view-as-menu { bottom: calc(100% + 10px); }
}

/* V169 Monthly Position Overview + QC Rotation Tracker */
.modal.modal-lg .modal-card {
  width: min(1280px, calc(100vw - 32px)) !important;
  max-height: 90vh !important;
}
.v169-overview-modal,
.v169-qc-modal {
  display: grid;
  gap: 14px;
}
.v169-overview-modal .section-title,
.v169-qc-modal .section-title {
  padding-right: 44px;
  align-items: flex-start;
}
.overview-block {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fbfdff;
  padding: 14px;
}
.overview-block h4 {
  margin: 0 0 8px;
  color: #203245;
}
.v169-overview-table {
  max-height: 58vh;
  border-radius: 16px;
}
.v169-overview-table table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 880px;
}
.v169-overview-table th,
.v169-overview-table td {
  white-space: nowrap;
  vertical-align: middle;
  text-align: center;
  min-width: 92px;
}
.v169-overview-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #f6f9fc;
}
.v169-overview-table .sticky-name-col {
  position: sticky;
  left: 0;
  z-index: 5;
  min-width: 180px;
  max-width: 220px;
  text-align: left;
  background: #fff;
  box-shadow: 8px 0 18px rgba(15, 35, 52, .08);
}
.v169-overview-table thead .sticky-name-col {
  z-index: 6;
  background: #f6f9fc;
}
.v169-overview-table .num-cell {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.v169-overview-table .has-count {
  color: #0f5d86;
  background: rgba(128,202,255,.10);
}
.v169-overview-table .zero-count {
  color: transparent;
}
.v169-overview-table .total-cell {
  color: #1f3b57;
  background: #eef7ff;
}
.position-summary-table table {
  min-width: 1400px;
}
.position-summary-table th:not(.sticky-name-col),
.position-summary-table td:not(.sticky-name-col) {
  min-width: 118px;
  max-width: 190px;
  white-space: normal;
  line-height: 1.25;
}
.qc-rotation-btn {
  border-color: #bfe7d3;
  background: #effbf4;
  color: #19774b;
}
.qc-staff-table .total-cell {
  min-width: 110px;
  font-size: 16px;
}
.qc-week-cell {
  text-align: left !important;
  min-width: 170px !important;
}
.qc-week-cell span {
  display: block;
  border-radius: 999px;
  padding: 4px 8px;
  margin: 2px 0;
  background: #eef7ff;
  color: #1f4f78;
  font-weight: 800;
}
.qc-empty {
  color: var(--muted);
  background: #fbfdff;
}
.qc-detail-table table {
  min-width: 780px;
}
.qc-detail-table th:first-child {
  min-width: 120px;
}
.qc-detail-table td {
  text-align: left;
  min-width: 250px;
  white-space: normal;
}
.qc-detail-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 3px 0;
}
@media (max-width: 720px) {
  .modal.modal-lg .modal-card {
    width: min(96vw, 100%) !important;
    padding: 16px !important;
  }
  .v169-overview-table .sticky-name-col {
    min-width: 135px;
  }
  .v169-overview-table th,
  .v169-overview-table td {
    min-width: 82px;
    font-size: 12px;
  }
}


/* V170 OT cross-day end date layout */
.v170-checkin-fields {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(220px, 1fr)) !important;
  gap: 14px !important;
  width: 100%;
}
.v170-checkin-fields label {
  min-width: 0;
}
.v170-checkin-fields input {
  width: 100%;
  min-width: 0;
}
@media (max-width: 820px) {
  .v170-checkin-fields { grid-template-columns: 1fr !important; }
}

/* V171: tighter sticky staff-name column for overview/QC tables */
.v169-overview-table .sticky-name-col {
  width: 136px !important;
  min-width: 136px !important;
  max-width: 152px !important;
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v169-overview-table .sticky-name-col .staff-color-pill {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 10px;
  padding-right: 10px;
}
.v169-overview-table tbody .sticky-name-col {
  z-index: 7;
  background: #fff;
}
.v169-overview-table thead .sticky-name-col {
  z-index: 9;
  background: #f6f9fc;
}
@media (max-width: 720px) {
  .v169-overview-table .sticky-name-col {
    width: 118px !important;
    min-width: 118px !important;
    max-width: 132px !important;
  }
}

/* V175: force freeze first column in Position Overview + QC Rotation modals */
.v169-overview-table {
  overflow-x: auto !important;
  overflow-y: auto !important;
  position: relative !important;
  background: #fff !important;
}
.v169-overview-table table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
  width: max-content !important;
  min-width: 100% !important;
}
.v169-overview-table table > thead > tr > th:first-child,
.v169-overview-table table > tbody > tr > th:first-child,
.v169-overview-table table > tbody > tr > td:first-child,
.v169-overview-table .sticky-name-col {
  position: sticky !important;
  left: 0 !important;
  background: #fff !important;
  z-index: 10 !important;
  box-shadow: 8px 0 18px rgba(15, 35, 52, .10) !important;
}
.v169-overview-table table > thead > tr > th:first-child,
.v169-overview-table thead .sticky-name-col {
  top: 0 !important;
  background: #f6f9fc !important;
  z-index: 11 !important;
}
.v169-overview-table table > tbody > tr > th:first-child,
.v169-overview-table table > tbody > tr > td:first-child,
.v169-overview-table tbody .sticky-name-col {
  background: #fff !important;
  z-index: 10 !important;
}
.v169-overview-table .sticky-name-col .staff-color-pill,
.v169-overview-table table > tbody > tr > th:first-child .staff-color-pill,
.v169-overview-table table > tbody > tr > td:first-child .staff-color-pill {
  position: relative;
  z-index: 12;
}

/* V178: freeze staff-name first column in Position Overview modal
   Scope: Popup "ภาพรวมจัดตำแหน่ง" only. Prevents the first column from disappearing during horizontal scroll. */
.v169-overview-modal .v169-overview-table {
  overflow-x: auto !important;
  overflow-y: auto !important;
  max-width: 100% !important;
  position: relative !important;
  isolation: isolate !important;
  background: #ffffff !important;
}

.v169-overview-modal .v169-overview-table table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
  width: max-content !important;
  min-width: 100% !important;
}

.v169-overview-modal .v169-overview-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 30 !important;
  background: #f6f9fc !important;
}

.v169-overview-modal .v169-overview-table table > thead > tr > th:first-child,
.v169-overview-modal .v169-overview-table table > tbody > tr > th:first-child,
.v169-overview-modal .v169-overview-table table > tbody > tr > td:first-child,
.v169-overview-modal .v169-overview-table .sticky-name-col {
  position: sticky !important;
  left: 0 !important;
  z-index: 40 !important;
  background: #ffffff !important;
  border-right: 1px solid rgba(23, 53, 77, .14) !important;
  box-shadow: 10px 0 20px rgba(15, 35, 52, .10) !important;
  transform: translateZ(0);
}

.v169-overview-modal .v169-overview-table table > thead > tr > th:first-child,
.v169-overview-modal .v169-overview-table thead .sticky-name-col {
  top: 0 !important;
  z-index: 60 !important;
  background: #f6f9fc !important;
}

.v169-overview-modal .v169-overview-table table > tbody > tr > th:first-child,
.v169-overview-modal .v169-overview-table table > tbody > tr > td:first-child,
.v169-overview-modal .v169-overview-table tbody .sticky-name-col {
  z-index: 45 !important;
  background: #ffffff !important;
}

.v169-overview-modal .v169-overview-table .sticky-name-col .staff-color-pill,
.v169-overview-modal .v169-overview-table table > tbody > tr > th:first-child .staff-color-pill,
.v169-overview-modal .v169-overview-table table > tbody > tr > td:first-child .staff-color-pill {
  position: relative;
  z-index: 70;
}

/* V179: hard fix for sticky first column in Position Overview / QC modal tables */
.v169-overview-modal,
.v169-qc-modal,
.v169-overview-modal .overview-block,
.v169-qc-modal .overview-block {
  min-width: 0 !important;
  max-width: 100% !important;
}

.v169-overview-modal .overview-block,
.v169-qc-modal .overview-block {
  overflow: visible !important;
}

.v179-freeze-table,
.table-responsive.v169-overview-table,
.v169-overview-modal .v169-overview-table,
.v169-qc-modal .v169-overview-table {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  overflow-y: auto !important;
  position: relative !important;
  background: #ffffff !important;
  -webkit-overflow-scrolling: touch;
}

.v179-freeze-table table,
.table-responsive.v169-overview-table table,
.v169-overview-modal .v169-overview-table table,
.v169-qc-modal .v169-overview-table table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
  width: max-content !important;
  min-width: 100% !important;
}

.v179-freeze-table th:first-child,
.v179-freeze-table td:first-child,
.table-responsive.v169-overview-table th:first-child,
.table-responsive.v169-overview-table td:first-child,
.v169-overview-modal .v169-overview-table th:first-child,
.v169-overview-modal .v169-overview-table td:first-child,
.v169-qc-modal .v169-overview-table th:first-child,
.v169-qc-modal .v169-overview-table td:first-child,
.v179-sticky-first-col {
  position: sticky !important;
  left: 0 !important;
  background-color: #ffffff !important;
  z-index: 70 !important;
  box-shadow: 10px 0 20px rgba(15, 35, 52, .10) !important;
  border-right: 1px solid rgba(23, 53, 77, .14) !important;
}

.v179-freeze-table thead th,
.table-responsive.v169-overview-table thead th,
.v169-overview-modal .v169-overview-table thead th,
.v169-qc-modal .v169-overview-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 80 !important;
  background: #f6f9fc !important;
}

.v179-freeze-table thead th:first-child,
.table-responsive.v169-overview-table thead th:first-child,
.v169-overview-modal .v169-overview-table thead th:first-child,
.v169-qc-modal .v169-overview-table thead th:first-child,
thead .v179-sticky-first-col {
  top: 0 !important;
  z-index: 90 !important;
  background-color: #f6f9fc !important;
}

/* V180 HR Dummy Export + Admin OT compact forms */
.v180-ot-page .section-title { align-items: flex-start; gap: 12px; }
.v180-admin-card .form-grid { align-items: end; }
.v180-admin-attendance-form,
.v180-admin-ot-extra-form { gap: 12px; }
.v180-admin-attendance-form .v180-calculated-hours {
  font-weight: 700;
  background: #eef8ff;
  border-color: rgba(63, 150, 205, .45);
}
.v180-admin-ot-extra-form textarea {
  min-height: 86px;
  resize: vertical;
}
.v180-ot-page [data-export-ot-hr-excel] {
  white-space: nowrap;
}
@media (max-width: 720px) {
  .v180-ot-page .section-title { align-items: stretch; }
  .v180-ot-page [data-export-ot-hr-excel] { width: 100%; }
}

/* V181 OT Claim History */
.v181-claim-history .section-title,
.v181-claim-batch .section-title { gap: 12px; align-items: flex-start; }
.v181-pending-summary table th,
.v181-pending-summary table td { white-space: nowrap; }
.danger-btn {
  border: 1px solid #fecaca;
  background: #fee2e2;
  color: #991b1b;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}
.danger-btn:hover { filter: brightness(.98); }
.v181-admin-card textarea { width: 100%; resize: vertical; }
@media (max-width: 780px) {
  .v181-ot-page .section-title { align-items: stretch; }
  .v181-ot-page .section-title .actions { width: 100%; display: grid; grid-template-columns: 1fr; }
}

/* V182 Dynamic Position Management */
.position-management-page { display: grid; gap: 16px; }
.position-management-page .position-master-zone { margin-top: 14px; }
.position-management-page .position-master-zone:first-child { margin-top: 0; }
.position-management-page .compact-table table td, .position-management-page .compact-table table th { vertical-align: top; }
.position-management-page .inactive-row { opacity: .62; }
.position-management-page .inactive-row td { background: #f8fafc; }
.position-management-page .position-master-form-card textarea { resize: vertical; min-height: 96px; }
.position-management-page .position-master-note-card code, .position-management-page code, .v182-eligibility-page code { background: #eef6ff; border: 1px solid #d7eaff; border-radius: 6px; padding: 1px 6px; }
.position-management-page .position-master-note-card .profile-info-list { margin-top: 10px; }
.v182-eligibility-page .position-check small { display: block; }
.v182-position-matrix .month-position-select { min-width: 120px; }

/* V183 OT approval date range filter */
.v183-ot-date-filter .ot-filter-actions{
  display:flex;
  flex:0 0 auto;
  gap:8px;
  align-items:flex-end;
  flex-wrap:wrap;
}
.v183-ot-date-filter .ot-filter-hint{
  flex:1 0 100%;
  margin:0;
}
@media(max-width:700px){
  .v183-ot-date-filter .ot-filter-actions{
    width:100%;
  }
  .v183-ot-date-filter .ot-filter-actions button{
    flex:1 1 auto;
  }
}


/* V184 Restore monthly position matrix styling
   Scope: only the monthly position matrix rendered by V182. */
.v182-position-matrix {
  --month-staff-col-width: 112px;
  --month-summary-col-width: 72px;
  --month-day-col-width: 108px;
  --month-row-height: 46px;
}
.v182-position-matrix .matrix-legend {
  margin-bottom: 10px;
}
.v182-position-matrix .month-position-matrix {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}
.v182-position-matrix .month-position-matrix table {
  table-layout: fixed !important;
  border-collapse: separate;
  border-spacing: 0;
  min-width: calc(var(--month-staff-col-width) + var(--month-summary-col-width) + (31 * var(--month-day-col-width)));
  width: max-content;
  background: #fff;
}
.v182-position-matrix .month-position-matrix th,
.v182-position-matrix .month-position-matrix td {
  box-sizing: border-box;
  height: var(--month-row-height);
  min-height: var(--month-row-height);
  padding: 7px 8px !important;
  text-align: center;
  vertical-align: middle;
  border-right: 1px solid #eef2f7;
  border-bottom: 1px solid #e5eaf0;
  overflow: hidden;
}
.v182-position-matrix .month-position-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #f8fafc;
  font-weight: 900;
}
.v182-position-matrix .month-position-matrix thead .missing-role-row th {
  top: 46px;
  z-index: 19;
}
.v182-position-matrix .month-position-matrix .staff-col {
  position: sticky !important;
  left: 0 !important;
  z-index: 30;
  width: var(--month-staff-col-width) !important;
  min-width: var(--month-staff-col-width) !important;
  max-width: var(--month-staff-col-width) !important;
  text-align: left;
  box-shadow: 4px 0 10px rgba(31, 50, 72, .08);
}
.v182-position-matrix .month-position-matrix thead .staff-col {
  z-index: 40;
  background: #f8fafc !important;
}
.v182-position-matrix .month-position-matrix .summary-col {
  position: sticky !important;
  left: var(--month-staff-col-width) !important;
  z-index: 28;
  width: var(--month-summary-col-width) !important;
  min-width: var(--month-summary-col-width) !important;
  max-width: var(--month-summary-col-width) !important;
  background: #fff;
  box-shadow: 4px 0 10px rgba(31, 50, 72, .05);
}
.v182-position-matrix .month-position-matrix thead .summary-col {
  z-index: 38;
  background: #f8fafc !important;
}
.v182-position-matrix .month-position-matrix .date-head,
.v182-position-matrix .month-position-matrix .missing-role-cell,
.v182-position-matrix .month-position-matrix .matrix-cell {
  width: var(--month-day-col-width) !important;
  min-width: var(--month-day-col-width) !important;
  max-width: var(--month-day-col-width) !important;
}
.v182-position-matrix .date-head {
  font-size: 12px;
  line-height: 1.15;
  white-space: nowrap;
}
.v182-position-matrix .date-head b,
.v182-position-matrix .date-head span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.v182-position-matrix .staff-color-cell {
  padding: 5px 8px !important;
  line-height: 1.05 !important;
}
.v182-position-matrix .matrix-staff-name {
  display: grid;
  gap: 2px;
  align-content: center;
  min-height: 30px;
  overflow: hidden;
}
.v182-position-matrix .matrix-staff-name b,
.v182-position-matrix .matrix-staff-name small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.v182-position-matrix .matrix-staff-name b {
  font-size: 12px;
  line-height: 1.1;
}
.v182-position-matrix .matrix-staff-name small {
  font-size: 9px;
  line-height: 1.05;
  opacity: .88;
}
.v182-position-matrix .summary-action-cell {
  padding: 5px 6px !important;
  text-align: center !important;
}
.v182-position-matrix .summary-action-cell .staff-summary-trigger {
  max-width: 100%;
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v182-position-matrix .matrix-cell {
  font-size: 12px;
  font-weight: 900;
  line-height: 1.18;
  background: #fff;
}
.v182-position-matrix .matrix-cell > span,
.v182-position-matrix .no-position-day span,
.v182-position-matrix .needs-review-cell span {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.v182-position-matrix .matrix-cell span br {
  display: none;
}
.v182-position-matrix .cell-note {
  display: none !important;
}
.v182-position-matrix .month-position-select {
  display: block;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  height: 32px;
  padding: 5px 7px !important;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v182-position-matrix .missing-role-cell {
  padding: 4px 5px !important;
  font-size: 10px;
  line-height: 1.1;
  white-space: nowrap !important;
}
.v182-position-matrix .missing-role-cell span {
  display: inline-block;
  max-width: calc(100% - 6px);
  margin: 0;
  padding: 2px 5px;
  border-radius: 999px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.v182-position-matrix .missing-role-cell span + span {
  display: none;
}
.v182-position-matrix .holiday-cell,
.v182-position-matrix .weekend-cell,
.v182-position-matrix .holiday-head,
.v182-position-matrix .weekend-head {
  background: #f1f5f9 !important;
  color: #334155 !important;
}
.v182-position-matrix .outing-cell,
.v182-position-matrix .outing-head {
  background: #ffe9ee !important;
  color: #b3354c !important;
}
.v182-position-matrix .needs-review-cell {
  background: #fff4df !important;
  color: #8a5a00 !important;
}
.v182-position-matrix tbody tr:nth-child(even) .matrix-cell:not(.holiday-cell):not(.weekend-cell):not(.outing-cell):not(.leave-cell):not(.needs-review-cell) {
  background: #fcfdff;
}
@media (max-width: 720px) {
  .v182-position-matrix {
    --month-staff-col-width: 96px;
    --month-summary-col-width: 62px;
    --month-day-col-width: 96px;
    --month-row-height: 44px;
  }
  .v182-position-matrix .month-position-matrix table {
    min-width: calc(var(--month-staff-col-width) + var(--month-summary-col-width) + (31 * var(--month-day-col-width)));
  }
  .v182-position-matrix .month-position-matrix thead .missing-role-row th {
    top: 44px;
  }
  .v182-position-matrix .month-position-matrix th,
  .v182-position-matrix .month-position-matrix td {
    padding: 5px 6px !important;
    font-size: 11px;
  }
  .v182-position-matrix .month-position-select {
    height: 30px;
    font-size: 10px;
  }
}


/* V185 Position monthly matrix layout/order fix
   Intentional scoped overrides only for monthly position matrix and position management page. */
.v182-position-matrix {
  --month-staff-col-width: 112px;
  --month-summary-col-width: 72px;
  --month-day-col-width: 108px;
  --month-header-height: 38px;
  --month-missing-height: 34px;
  --month-row-height: 36px;
}
.v182-position-matrix .month-position-matrix {
  max-width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}
.v182-position-matrix .month-position-matrix table {
  table-layout: fixed !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  width: calc(var(--month-staff-col-width) + var(--month-summary-col-width) + (31 * var(--month-day-col-width))) !important;
  min-width: calc(var(--month-staff-col-width) + var(--month-summary-col-width) + (31 * var(--month-day-col-width))) !important;
}
.v182-position-matrix .month-position-matrix th,
.v182-position-matrix .month-position-matrix td {
  box-sizing: border-box;
  height: var(--month-row-height);
  min-height: var(--month-row-height);
  max-height: var(--month-row-height);
  padding: 4px 6px !important;
  overflow: hidden !important;
  vertical-align: middle !important;
  white-space: nowrap;
}
.v182-position-matrix .month-position-matrix thead tr:first-child th {
  height: var(--month-header-height);
  min-height: var(--month-header-height);
  max-height: var(--month-header-height);
  position: sticky !important;
  top: 0 !important;
  z-index: 40;
  background: #f8fafc !important;
}
.v182-position-matrix .month-position-matrix thead .missing-role-row th {
  height: var(--month-missing-height);
  min-height: var(--month-missing-height);
  max-height: var(--month-missing-height);
  position: sticky !important;
  top: var(--month-header-height) !important;
  z-index: 39;
  background: #fff !important;
}
.v182-position-matrix .month-position-matrix .staff-col {
  position: sticky !important;
  left: 0 !important;
  z-index: 50 !important;
  width: var(--month-staff-col-width) !important;
  min-width: var(--month-staff-col-width) !important;
  max-width: var(--month-staff-col-width) !important;
  background-clip: padding-box;
}
.v182-position-matrix .month-position-matrix .summary-col {
  position: sticky !important;
  left: var(--month-staff-col-width) !important;
  z-index: 49 !important;
  width: var(--month-summary-col-width) !important;
  min-width: var(--month-summary-col-width) !important;
  max-width: var(--month-summary-col-width) !important;
  background: #fff !important;
  background-clip: padding-box;
}
.v182-position-matrix .month-position-matrix thead .staff-col {
  z-index: 70 !important;
  background: #f8fafc !important;
}
.v182-position-matrix .month-position-matrix thead .summary-col {
  z-index: 69 !important;
  background: #f8fafc !important;
}
.v182-position-matrix .month-position-matrix thead .missing-role-row .staff-col,
.v182-position-matrix .month-position-matrix thead .missing-role-row .summary-col {
  background: #ffffff !important;
}
.v182-position-matrix .month-position-matrix .date-head,
.v182-position-matrix .month-position-matrix .missing-role-cell,
.v182-position-matrix .month-position-matrix .matrix-cell {
  width: var(--month-day-col-width) !important;
  min-width: var(--month-day-col-width) !important;
  max-width: var(--month-day-col-width) !important;
}
.v182-position-matrix .date-head,
.v182-position-matrix .date-head b,
.v182-position-matrix .date-head span,
.v182-position-matrix .matrix-cell,
.v182-position-matrix .matrix-cell span,
.v182-position-matrix .missing-role-cell,
.v182-position-matrix .missing-role-cell span,
.v182-position-matrix .matrix-staff-name b,
.v182-position-matrix .matrix-staff-name small {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}
.v182-position-matrix .matrix-cell {
  font-size: 11px;
  line-height: 1.1;
  font-weight: 900;
}
.v182-position-matrix .matrix-cell > span {
  display: block;
  max-width: 100%;
}
.v182-position-matrix .matrix-cell br,
.v182-position-matrix .cell-note {
  display: none !important;
}
.v182-position-matrix .staff-color-cell {
  padding: 4px 7px !important;
}
.v182-position-matrix .matrix-staff-name {
  display: block;
  min-height: 0;
  max-height: calc(var(--month-row-height) - 8px);
}
.v182-position-matrix .matrix-staff-name b {
  display: block;
  font-size: 12px;
  line-height: 1.05;
}
.v182-position-matrix .matrix-staff-name small {
  display: block;
  font-size: 9px;
  line-height: 1.05;
  margin-top: 1px;
}
.v182-position-matrix .summary-action-cell {
  padding: 4px 5px !important;
  text-align: center !important;
}
.v182-position-matrix .summary-action-cell .staff-summary-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-width: 52px;
  height: 24px;
  padding: 3px 8px !important;
  border-radius: 999px !important;
  border: 1px solid #b9dcff !important;
  background: #e8f4ff !important;
  color: #1769aa !important;
  font-size: 10px !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  box-shadow: none !important;
}
.v182-position-matrix .month-position-select {
  height: 28px !important;
  min-height: 28px !important;
  padding: 3px 6px !important;
  border-radius: 9px !important;
  font-size: 10px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}
.v182-position-matrix .missing-role-cell {
  padding: 3px 4px !important;
  font-size: 9px !important;
  line-height: 1 !important;
}
.v182-position-matrix .missing-role-cell span {
  display: inline-block;
  max-width: 100%;
  padding: 2px 5px;
  border-radius: 999px;
}
.v182-position-matrix .missing-role-cell span + span {
  display: none !important;
}
.v182-position-matrix .missing-role-cell.complete {
  background: #eefdf3 !important;
  color: #166534 !important;
}
.v182-position-matrix .missing-role-cell.has-missing {
  background: #fff7ed !important;
  color: #9a3412 !important;
}
.v182-position-matrix .missing-role-cell.no-position-day {
  background: #eef2f7 !important;
  color: #475569 !important;
}

.position-management-page {
  display: grid;
  gap: 14px;
}
.position-management-page .position-management-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.position-management-page .position-collapse-card {
  display: block;
  padding: 0;
  overflow: hidden;
}
.position-management-page .position-collapse-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}
.position-management-page .position-collapse-card > summary::-webkit-details-marker {
  display: none;
}
.position-management-page .position-collapse-card > summary::after {
  content: "⌄";
  flex: 0 0 auto;
  font-weight: 900;
  color: #64748b;
}
.position-management-page .position-collapse-card[open] > summary::after {
  transform: rotate(180deg);
}
.position-management-page .position-collapse-card > summary span {
  display: grid;
  gap: 3px;
}
.position-management-page .position-collapse-card > summary small {
  color: #64748b;
  font-weight: 600;
}
.position-management-page .position-master-form-card form,
.position-management-page .position-master-form-card > p,
.position-management-page .position-master-note-card .profile-info-list,
.position-management-page .position-master-note-card > p {
  margin: 0 18px 18px;
}
.position-management-page .position-advanced-options {
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 10px 12px;
  background: #f8fafc;
}
.position-management-page .position-advanced-options > summary {
  cursor: pointer;
  font-weight: 800;
  color: #334155;
}
.position-management-page .position-master-list-card .position-master-zone + .position-master-zone {
  margin-top: 18px;
}
.position-management-page .compact-table table {
  table-layout: auto;
}
.position-management-page .compact-table th,
.position-management-page .compact-table td {
  white-space: normal;
}
@media (max-width: 720px) {
  .v182-position-matrix {
    --month-staff-col-width: 96px;
    --month-summary-col-width: 62px;
    --month-day-col-width: 96px;
    --month-header-height: 36px;
    --month-row-height: 34px;
  }
  .position-management-page .position-management-actions,
  .position-management-page .position-collapse-card > summary {
    align-items: stretch;
    flex-direction: column;
  }
}

/* V190 HR Rate Normalization */
.v190-ot-table th:nth-child(4),
.v190-ot-table th:nth-child(5),
.v190-ot-table td:nth-child(4),
.v190-ot-table td:nth-child(5),
.v190-pending-summary th:nth-child(2),
.v190-pending-summary th:nth-child(3),
.v190-pending-summary td:nth-child(2),
.v190-pending-summary td:nth-child(3) {
  text-align: right;
  white-space: nowrap;
}
.v190-ot-table .badge.yellow,
.v190-ot-cards .badge.yellow {
  margin-top: 3px;
  display: inline-flex;
}

/* V191 OT approval RBAC + Admin edit/delete */
.v191-ot-table th:last-child,
.v191-ot-table td:last-child { min-width: 210px; }
.v191-ot-actions {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  align-items:center;
  justify-content:flex-start;
}
.v191-ot-actions .tiny-btn { white-space:nowrap; }
.v191-ot-actions .icon-btn { min-width:32px; padding:4px 7px; line-height:1; }
.v191-status-actions {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  align-items:center;
  padding-left:6px;
  border-left:1px solid rgba(0,0,0,.08);
}
.v191-ot-edit-modal .notice { margin: 8px 0 14px; }
.v191-ot-edit-modal .form-grid label textarea { width:100%; }
.v191-approval-reset { display:flex; gap:8px; align-items:flex-start; padding:10px 12px; border-radius:12px; background:#fff8d7; }
.v191-approval-reset input { margin-top:3px; }
@media (max-width: 760px) {
  .v191-ot-actions, .v191-status-actions { width:100%; }
  .v191-status-actions { border-left:0; padding-left:0; }
}


/* V193: centered OT edit modal with dimmed overlay and smooth transition */
.modal.modal-ot-edit-v193 {
  position: fixed !important;
  inset: 0 !important;
  display: block !important;
  width: 100vw !important;
  height: 100vh !important;
  padding: 0 !important;
  background: rgba(15, 23, 42, .48) !important;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 12000 !important;
  opacity: 1;
  transition: opacity .18s ease;
}
.modal.modal-ot-edit-v193.modal-closing {
  opacity: 0;
  pointer-events: none;
}
.modal.modal-ot-edit-v193 .modal-card {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  width: min(720px, calc(100vw - 32px)) !important;
  max-height: min(86vh, 780px) !important;
  overflow: auto !important;
  border-radius: 28px !important;
  padding: 24px !important;
  box-shadow: 0 30px 90px rgba(15, 23, 42, .34) !important;
  transform: translate(-50%, -50%) scale(1);
  animation: otEditModalCenterInV193 .18s cubic-bezier(.2,.85,.25,1) both !important;
  will-change: opacity, transform;
}
.modal.modal-ot-edit-v193.modal-closing .modal-card {
  animation: none !important;
  opacity: 0;
  transform: translate(-50%, calc(-50% + 10px)) scale(.985) !important;
  transition: opacity .18s ease, transform .18s ease;
}
.modal.modal-ot-edit-v193 .v191-ot-edit-modal h2 {
  margin-top: 0;
  padding-right: 34px;
}
.modal.modal-ot-edit-v193 .v191-ot-edit-modal .modal-form-actions {
  position: sticky;
  bottom: -24px;
  background: linear-gradient(180deg, rgba(255,255,255,.80), #fff 42%);
  padding-top: 14px;
  margin-top: 4px;
}
@keyframes otEditModalCenterInV193 {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 12px)) scale(.975);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}
@media (max-width: 760px) {
  .modal.modal-ot-edit-v193 .modal-card {
    width: min(94vw, 720px) !important;
    max-height: 88vh !important;
    padding: 20px !important;
    border-radius: 24px !important;
  }
  .modal.modal-ot-edit-v193 .v191-ot-edit-modal .form-grid {
    grid-template-columns: 1fr !important;
  }
  .modal.modal-ot-edit-v193 .v191-ot-edit-modal .modal-form-actions {
    bottom: -20px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .modal.modal-ot-edit-v193,
  .modal.modal-ot-edit-v193 .modal-card,
  .modal.modal-ot-edit-v193.modal-closing .modal-card {
    animation: none !important;
    transition: none !important;
  }
}

/* V198 Mobile-only responsive UX fixes */
@media (max-width: 820px) {
  /* 1) Calendar กลาง: compact card, show main events only, keep popup by data-day-detail */
  .compact-calendar-list.mobile-calendar-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .compact-calendar-card.mobile-day-card {
    min-width: 0;
    border-radius: 14px;
    padding: 8px;
    gap: 5px;
    overflow: hidden;
  }
  .compact-calendar-card .mobile-day-head {
    gap: 5px;
    margin: 0;
  }
  .compact-calendar-card .mobile-day-head b { font-size: 16px; }
  .compact-calendar-card .mobile-day-head span { font-size: 11px; }
  .compact-calendar-card .tiny-btn {
    min-height: 22px;
    padding: 2px 6px;
    font-size: 10px;
  }
  .compact-calendar-card .event-pill {
    width: 100%;
    max-width: 100%;
    min-height: 0;
    padding: 3px 6px;
    font-size: 10px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-more-count {
    border: 0;
    background: transparent;
    color: #2563eb;
    font-weight: 800;
    font-size: 11px;
    text-align: left;
    padding: 2px 0 0;
  }
  .mobile-calendar-tools { gap: 6px; align-items: center; }
  .mobile-calendar-tools .hint { font-size: 11px; }

  /* 2) ตารางทั้งเดือน: shrink ดูสรุป / staff summary buttons only on mobile */
  .staff-summary-trigger,
  .v159-position-matrix .summary-action-cell .staff-summary-trigger,
  .v182-position-matrix .summary-action-cell .staff-summary-trigger {
    min-width: 44px !important;
    max-width: 64px !important;
    padding: 2px 5px !important;
    font-size: 9px !important;
    line-height: 1.15 !important;
    border-radius: 8px !important;
  }
  .staff-summary-trigger span,
  .v159-position-matrix .summary-action-cell .staff-summary-trigger span,
  .v182-position-matrix .summary-action-cell .staff-summary-trigger span {
    font-size: 8px !important;
    padding: 1px 4px !important;
    margin-top: 2px !important;
  }

  /* 3) ตารางเวรประจำเดือน > ดูตามวัน: single day control */
  .single-day-control {
    display: flex;
    align-items: end;
    gap: 8px;
    margin: 6px 0 10px;
  }
  .single-day-control label {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    font-size: 12px;
  }
  .single-day-control input { width: 100%; }
  .single-day-cards.clean-calendar-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .single-day-cards .clean-day-card { padding: 10px; }

  /* 4) ดูสมดุลเวร: first column stays useful but not too wide */
  .clean-balance-dashboard .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .clean-balance-table {
    width: max-content !important;
    min-width: max-content !important;
    table-layout: auto !important;
  }
  .clean-balance-table th,
  .clean-balance-table td {
    font-size: 10px !important;
    padding: 4px 5px !important;
    white-space: nowrap;
  }
  .clean-balance-table th:first-child,
  .clean-balance-table td:first-child {
    position: sticky !important;
    left: 0 !important;
    z-index: 22 !important;
    min-width: 72px !important;
    width: 72px !important;
    max-width: 72px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    background: #fff !important;
    box-shadow: 2px 0 0 #e5e7eb !important;
  }
  .clean-balance-table thead th:first-child {
    z-index: 26 !important;
    background: #f8fafc !important;
  }
  .clean-balance-table td:first-child .staff-pill,
  .clean-balance-table td:first-child button,
  .clean-balance-table td:first-child span {
    max-width: 62px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
}

@media (max-width: 420px) {
  .compact-calendar-list.mobile-calendar-list { grid-template-columns: 1fr 1fr; }
  .compact-calendar-card .event-pill { font-size: 9.5px; }
}
@media (max-width: 820px) {
  .clean-summary-cell .tiny-btn,
  .clean-summary-head,
  .clean-schedule-grid .clean-summary-cell button[data-staff-stat] {
    font-size: 9px !important;
    line-height: 1.1 !important;
    padding: 2px 4px !important;
    min-height: 22px !important;
    min-width: 42px !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
  }
}

/* V201 Mobile calendar grid + balance table horizontal scroll */
@media (max-width: 820px) {
  /* ตารางสรุปสมดุลเวร: ให้ตารางเลื่อนซ้าย-ขวาในกรอบของตัวเอง ไม่ดันหน้าจอหลัก */
  .clean-schedule-content,
  .clean-balance-dashboard,
  .grouped-balance-dashboard,
  .balance-group-section {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .balance-group-section {
    overflow: hidden !important;
  }
  .clean-balance-dashboard .table-wrap,
  .grouped-balance-dashboard .table-wrap,
  .balance-group-section .table-wrap {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
  }
  .clean-balance-table {
    width: max-content !important;
    min-width: 780px !important;
    table-layout: auto !important;
  }
  .clean-balance-table th,
  .clean-balance-table td {
    white-space: nowrap !important;
  }

  /* Calendar กลาง: บังคับเป็น Grid 7 วันพอดีจอมือถือ */
  .calendar-shell {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }
  .calendar-grid.calendar-card-grid.calendar-mobile-seven {
    display: grid !important;
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: 4px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: visible !important;
    padding: 0 !important;
  }
  .calendar-grid.calendar-card-grid.calendar-mobile-seven .calendar-dayname {
    display: block !important;
    min-width: 0 !important;
    padding: 2px 0 4px !important;
    font-size: 11px !important;
    line-height: 1.1 !important;
    text-align: center !important;
    position: static !important;
  }
  .calendar-grid.calendar-card-grid.calendar-mobile-seven .calendar-card-cell {
    min-width: 0 !important;
    width: auto !important;
    max-width: 100% !important;
    min-height: 104px !important;
    border-radius: 12px !important;
    padding: 5px 4px !important;
    gap: 3px !important;
    overflow: hidden !important;
  }
  .calendar-grid.calendar-card-grid.calendar-mobile-seven .day-num {
    justify-content: flex-start !important;
    gap: 0 !important;
    font-size: 14px !important;
    line-height: 1 !important;
    min-width: 0 !important;
  }
  .calendar-grid.calendar-card-grid.calendar-mobile-seven .fake-btn {
    display: none !important;
  }
  .calendar-grid.calendar-card-grid.calendar-mobile-seven .event-pill {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 2px 4px !important;
    border-radius: 8px !important;
    font-size: 9px !important;
    line-height: 1.15 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .calendar-grid.calendar-card-grid.calendar-mobile-seven .hint {
    display: block !important;
    margin: 1px 0 0 !important;
    font-size: 10px !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}

@media (max-width: 420px) {
  .calendar-grid.calendar-card-grid.calendar-mobile-seven {
    gap: 3px !important;
  }
  .calendar-grid.calendar-card-grid.calendar-mobile-seven .calendar-card-cell {
    min-height: 98px !important;
    border-radius: 11px !important;
    padding: 4px 3px !important;
  }
  .calendar-grid.calendar-card-grid.calendar-mobile-seven .event-pill {
    font-size: 8.4px !important;
    padding: 2px 3px !important;
  }
}

/* V205 OT Summary + Partial Trade */
.v205-pending-summary table { min-width: 1080px; }
.v205-pending-summary th:nth-child(4),
.v205-pending-summary td:nth-child(4),
.v205-pending-summary th:nth-child(5),
.v205-pending-summary td:nth-child(5) { white-space: nowrap; }
#tradeEstimateV205 { line-height: 1.7; }
@media (max-width: 820px) {
  .v205-pending-summary table { min-width: 980px; }
}

/* V206 My Duty Today / Month checklist */
.my-duty-today-card .section-title { align-items: flex-start; }
.my-duty-detail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.my-duty-detail > div {
  border: 1px solid var(--border, #dfe8f3);
  background: #f8fbff;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.my-duty-detail b { font-size: 1.02rem; }
.my-duty-empty {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border: 1px dashed var(--border, #dfe8f3);
  border-radius: 14px;
  background: #f8fbff;
  margin: 10px 0;
}
.my-duty-month-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.my-duty-month-filter input { min-width: 150px; }
.my-duty-month-table td { vertical-align: top; }
.my-duty-month-cards { display: none; }
.v206-schedule-page .toolbar { gap: 10px; flex-wrap: wrap; }
@media (max-width: 760px) {
  .my-duty-detail { grid-template-columns: 1fr; }
  .my-duty-month-table { display: none; }
  .my-duty-month-cards { display: grid; }
  .my-duty-month-section .section-title { align-items: stretch; }
  .my-duty-month-filter { width: 100%; justify-content: space-between; }
  .my-duty-month-filter input { width: 160px; }
}

/* V209: ช4 / งานปั่นเลือด confirmation flow */
.ch4-duty-today-box {
  margin-top: 12px;
}
.ch4-duty-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}
.ch4-duty-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(23, 53, 77, .10);
  border-radius: 14px;
  background: rgba(255,255,255,.72);
}
.ch4-duty-item .actions,
.ch4-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.v209-admin-ch4-card table td,
.v209-admin-ch4-card table th {
  white-space: nowrap;
}
.v209-ch4-cover-modal textarea {
  width: 100%;
  resize: vertical;
}
@media (max-width: 768px) {
  .ch4-duty-item {
    align-items: stretch;
    flex-direction: column;
  }
  .ch4-duty-item .actions,
  .ch4-actions {
    justify-content: stretch;
  }
  .ch4-actions button {
    flex: 1 1 140px;
  }
}

/* V215 Weekly Position Copy */
.week-copy-source-v215,
.week-copy-checkbox-v215 {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.week-copy-source-v215 input[type="date"] {
  min-width: 145px;
}
.week-copy-checkbox-v215 input {
  width: auto;
}
.week-copy-btn-v215 {
  border-color: #bae6fd;
  background: #eff6ff;
}
.week-copy-cell-v215 {
  background: #e8f7ff !important;
  box-shadow: inset 0 0 0 2px #bae6fd;
}
.week-copy-cell-v215 select {
  background: #f0fbff !important;
  border-color: #7dd3fc !important;
}
@media (max-width: 768px) {
  .week-copy-source-v215,
  .week-copy-checkbox-v215,
  .week-copy-btn-v215 {
    width: 100%;
    justify-content: flex-start;
  }
  .week-copy-source-v215 input[type="date"] {
    width: 100%;
  }
}

/* V219 OT repair + compact daily position UX */
.v219-ot-page .v219-ot-card .hint,
.v219-positions-page .hint { line-height: 1.35; }
.v219-duty-detail { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 10px 0 12px; }
.v219-duty-detail > div { border: 1px solid var(--line, #e5edf5); background: #f8fbff; border-radius: 12px; padding: 10px 12px; min-height: 58px; }
.v219-duty-detail span { display:block; font-size: 12px; margin-bottom: 4px; }
.v219-duty-detail b { display:block; font-size: 14px; }
.v219-ot-actions { margin-top: 10px; }
.v219-ot-repair-panel .actions { margin-top: 8px; }
.v219-position-toolbar { align-items: end; gap: 8px; }
.v219-position-note { margin: 10px 0; }
.v219-daily-position-table th:nth-child(6),
.v219-daily-position-table td:nth-child(6) { min-width: 170px; }
.v219-daily-position-table td { vertical-align: middle; }
.v219-position-select { min-width: 160px; width: 100%; max-width: 240px; }
.v219-job-short { display:block; margin-top: 4px; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v219-position-card .actions { margin-top: 8px; }
@media (max-width: 760px) {
  .v219-duty-detail { grid-template-columns: 1fr; }
  .v219-position-select { max-width: none; }
  .v219-position-toolbar { align-items: stretch; }
}

/* V228 weekly leave-aware monthly position plan */
.v228-position-matrix {
  --month-header-height: 38px;
  --month-count-height: 30px;
  --month-missing-height: 32px;
  --month-row-height: 34px;
}
.v228-position-matrix .month-position-matrix thead .count-role-row th {
  height: var(--month-count-height) !important;
  min-height: var(--month-count-height) !important;
  max-height: var(--month-count-height) !important;
  position: sticky !important;
  top: var(--month-header-height) !important;
  z-index: 39;
  background: #fff7ed !important;
}
.v228-position-matrix .month-position-matrix thead .missing-role-row th {
  top: calc(var(--month-header-height) + var(--month-count-height)) !important;
}
.v228-position-matrix .count-role-cell {
  width: var(--month-day-col-width) !important;
  min-width: var(--month-day-col-width) !important;
  max-width: var(--month-day-col-width) !important;
  padding: 3px 4px !important;
  font-size: 10px !important;
  line-height: 1.05 !important;
  background: #fff7ed !important;
  color: #9a3412 !important;
  white-space: nowrap !important;
}
.v228-position-matrix .count-role-cell.complete {
  background: #f0fdf4 !important;
  color: #166534 !important;
}
.v228-position-matrix .count-role-cell.no-position-day {
  background: #eef2f7 !important;
  color: #475569 !important;
}
.v228-position-matrix .leave-note-v228 {
  display: block !important;
  max-width: 100%;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 8px;
  line-height: 1;
  opacity: .9;
}
.v228-position-matrix .matrix-cell.leave-cell > span {
  display: block;
}
.v228-position-matrix .matrix-cell.leave-cell .month-position-select {
  border-color: #f9c74f !important;
  background: rgba(255,255,255,.92) !important;
}

/* =========================
   V234 OT Admin / CH4 / HR Export UI
   ========================= */
.v234-ot-page .wide-card,
.v234-admin-follow-card,
.v234-ch4-shared-card { min-width: 0; }
.v234-admin-filters,
.v234-hr-filter { gap: 10px; align-items: end; }
.v234-statline { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.v234-follow-table table th,
.v234-follow-table table td,
.v234-ot-summary-table table th,
.v234-ot-summary-table table td { vertical-align: top; }
.link-btn.v234-staff-link { border: 0; background: transparent; padding: 0; cursor: pointer; color: inherit; text-decoration: none; }
.link-btn.v234-staff-link:hover { text-decoration: underline; }
.v234-staff-detail { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border, #e5e7eb); scroll-margin-top: 90px; }
.v234-ch4-actions { gap: 6px; flex-wrap: wrap; }
.v234-ch4-actions .tiny-btn { white-space: nowrap; }
.v234-hr-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 10px 0 12px; }
.v234-hr-cards .mini-stat { border: 1px solid var(--border, #e5e7eb); border-radius: 14px; padding: 12px; background: #fff; }
.v234-hr-cards .mini-stat span { display: block; font-size: 0.85rem; color: var(--muted, #64748b); }
.v234-hr-cards .mini-stat b { display: block; font-size: 1.45rem; margin-top: 4px; }
.v234-hr-cards .mini-stat.ready { background: #ecfdf5; }
.v234-hr-cards .mini-stat.overdue { background: #fff7ed; }
.v234-summary-block { margin-top: 14px; }
.v234-summary-block h4 { margin: 0 0 8px; }
.v234-admin-card .hint.compact,
.v234-hr-summary .hint.compact { margin-top: 6px; }

@media (max-width: 720px) {
  .v234-hr-cards { grid-template-columns: 1fr; }
  .v234-statline { justify-content: flex-start; }
  .v234-admin-filters label,
  .v234-hr-filter label { width: 100%; }
  .v234-ch4-actions .tiny-btn { width: 100%; }
}

/* =========================
   V236 OT / CH4 tracking readability fix
   ========================= */
.v236-note-cell {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 240px;
  max-width: 560px;
  line-height: 1.35;
}
.v236-note-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 6px;
  border: 1px solid #e5edf7;
  border-radius: 10px;
  background: #fbfdff;
  word-break: break-word;
}
.v236-note-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  background: #e0f2fe;
  color: #075985;
}
.v236-note-status.green { background: #dcfce7; color: #166534; }
.v236-note-status.orange { background: #ffedd5; color: #9a3412; }
.v236-note-status.red { background: #fee2e2; color: #991b1b; }
.v236-note-status.black { background: #e5e7eb; color: #374151; }
.v236-note-status.blue { background: #dbeafe; color: #1d4ed8; }
.v236-ch4-month-table {
  max-height: 430px;
  overflow: auto;
  border-radius: 14px;
}
.v234-admin-follow-card {
  scroll-margin-top: 88px;
}
.v234-admin-follow-card .v234-statline .badge.blue:first-child {
  margin-right: 4px;
}
.v234-follow-table th:nth-child(5),
.v234-follow-table td:nth-child(5) {
  min-width: 300px;
}
.v234-ch4-shared-card th:nth-child(6),
.v234-ch4-shared-card td:nth-child(6) {
  min-width: 280px;
}
@media (max-width: 720px) {
  .v236-note-cell { min-width: 220px; max-width: none; }
  .v236-note-line { font-size: .9rem; }
  .v236-ch4-month-table { max-height: 360px; }
}

/* V241 OT single-menu sub tabs */
.v241-ot-page { display:block; }
.v241-ot-menu-card { margin-bottom:16px; }
.v241-ot-tabs { display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.v241-ot-tab { border:1px solid #d7e7f7; background:#fff; color:#2d4b68; border-radius:999px; padding:10px 14px; font-weight:700; cursor:pointer; box-shadow:0 4px 12px rgba(31,82,126,.06); }
.v241-ot-tab.active { background:#75c3f7; color:#12334b; border-color:#75c3f7; }
.v241-ot-content > .v241-export-history, .v241-ot-content > .v241-export-batch { grid-column:1/-1; }
.v241-ot-summary .section-title { align-items:flex-start; }
.v241-logic-notice { border:1px solid #b8dcff; background:#eef7ff; color:#17446b; }
.v241-summary-block { margin-top:14px; }
.v241-separator { border:0; border-top:1px dashed #d7e7f7; margin:18px 0; }
.v241-month-filter, .v241-hr-filter { margin:10px 0 12px; }
.v241-export-history { display:grid; grid-template-columns:1fr; gap:14px; width:100%; }
.v241-export-batch { width:100%; }
@media (max-width: 720px) {
  .v241-ot-tabs { gap:8px; }
  .v241-ot-tab { width:100%; text-align:left; border-radius:16px; }
}


/* V268 Monthly daytime-position matrix: fixed widths + two sticky columns.
   Scope is limited to the latest V265 matrix renderer so scheduling logic is untouched. */
.v265-position-matrix {
  --v268-staff-col-width: 128px;
  --v268-summary-col-width: 84px;
  --v268-day-col-width: 108px;
  --v268-head-row-height: 42px;
  --v268-count-row-height: 36px;
  --v268-missing-row-height: 36px;
  min-width: 0;
  max-width: 100%;
}
.v265-position-matrix .month-position-matrix {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  isolation: isolate;
}
.v265-position-matrix .month-position-matrix table {
  table-layout: fixed !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  width: max-content !important;
  min-width: max-content !important;
  margin: 0;
}
.v265-position-matrix .month-position-matrix th,
.v265-position-matrix .month-position-matrix td {
  box-sizing: border-box !important;
  position: static;
  min-width: 0;
  padding: 6px 9px !important;
  vertical-align: middle !important;
  border-right: 1px solid #e5eaf0;
  background-clip: padding-box !important;
}
.v265-position-matrix .month-position-matrix .staff-col {
  position: sticky !important;
  left: 0 !important;
  width: var(--v268-staff-col-width) !important;
  min-width: var(--v268-staff-col-width) !important;
  max-width: var(--v268-staff-col-width) !important;
  text-align: left !important;
  z-index: 32 !important;
  box-shadow: 1px 0 0 #d9e2ec, 5px 0 10px rgba(31, 50, 72, .07) !important;
}
.v265-position-matrix .month-position-matrix .summary-col {
  position: sticky !important;
  left: var(--v268-staff-col-width) !important;
  width: var(--v268-summary-col-width) !important;
  min-width: var(--v268-summary-col-width) !important;
  max-width: var(--v268-summary-col-width) !important;
  text-align: center !important;
  z-index: 31 !important;
  background: #fff !important;
  box-shadow: 1px 0 0 #d9e2ec, 5px 0 10px rgba(31, 50, 72, .06) !important;
}
.v265-position-matrix .month-position-matrix .date-head,
.v265-position-matrix .month-position-matrix .count-role-cell,
.v265-position-matrix .month-position-matrix .missing-role-cell,
.v265-position-matrix .month-position-matrix .matrix-cell {
  width: var(--v268-day-col-width) !important;
  min-width: var(--v268-day-col-width) !important;
  max-width: var(--v268-day-col-width) !important;
}
.v265-position-matrix .month-position-matrix thead th {
  position: sticky !important;
  background: #f8fafc !important;
}
.v265-position-matrix .month-position-matrix thead tr:first-child th {
  top: 0 !important;
  height: var(--v268-head-row-height) !important;
  z-index: 40 !important;
}
.v265-position-matrix .month-position-matrix thead .count-role-row th {
  top: var(--v268-head-row-height) !important;
  height: var(--v268-count-row-height) !important;
  z-index: 39 !important;
}
.v265-position-matrix .month-position-matrix thead .missing-role-row th {
  top: calc(var(--v268-head-row-height) + var(--v268-count-row-height)) !important;
  height: var(--v268-missing-row-height) !important;
  z-index: 38 !important;
}
.v265-position-matrix .month-position-matrix thead .staff-col {
  z-index: 62 !important;
  background: #f8fafc !important;
}
.v265-position-matrix .month-position-matrix thead .summary-col {
  z-index: 61 !important;
  background: #f8fafc !important;
}
.v265-position-matrix .month-position-matrix tbody .staff-col {
  overflow: hidden;
  background-color: #fff;
}
.v265-position-matrix .month-position-matrix .matrix-staff-name,
.v265-position-matrix .month-position-matrix .matrix-staff-name b,
.v265-position-matrix .month-position-matrix .matrix-staff-name small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.v265-position-matrix .month-position-matrix .summary-action-cell .staff-summary-trigger {
  width: 100%;
  max-width: 100%;
  min-width: 0 !important;
  padding: 5px 6px !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v265-position-matrix .month-position-matrix .month-position-select {
  display: block;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

/* The longer menu/header wording must wrap instead of overflowing on tablets and phones. */
.nav-btn > span:last-child,
#pageTitle,
.readonly-month-position-page .section-title h3 {
  overflow-wrap: anywhere;
}
@media (max-width: 760px) {
  .v265-position-matrix {
    --v268-staff-col-width: 108px;
    --v268-summary-col-width: 72px;
    --v268-day-col-width: 96px;
    --v268-head-row-height: 40px;
    --v268-count-row-height: 34px;
    --v268-missing-row-height: 34px;
  }
  .v265-position-matrix .month-position-matrix th,
  .v265-position-matrix .month-position-matrix td {
    padding: 5px 7px !important;
    font-size: 10px !important;
  }
  .nav-btn > span:last-child {
    min-width: 0;
    white-space: normal;
    line-height: 1.25;
  }
  #pageTitle {
    min-width: 0;
    font-size: clamp(18px, 5vw, 22px);
    line-height: 1.25;
  }
  .readonly-month-position-page .section-title h3 {
    font-size: 16px;
    line-height: 1.3;
  }
}
@media (max-width: 420px) {
  .v265-position-matrix {
    --v268-staff-col-width: 100px;
    --v268-summary-col-width: 68px;
    --v268-day-col-width: 92px;
  }
}
