#adminPageAttendance {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.attendance-page {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px 40px;
  box-sizing: border-box;
  color: #29463b;
}

.attendance-page * { box-sizing: border-box; }
.attendance-page h1, .attendance-page h2, .attendance-page p { margin: 0; }
.attendance-page h1 { color: #24483a; font-size: 26px; line-height: 1.25; }
.attendance-page h2 { color: #2d5545; font-size: 17px; line-height: 1.35; }
.attendance-page button, .attendance-page input { font: inherit; }
.attendance-page button:focus-visible, .attendance-page input:focus-visible { outline: 3px solid #b88948; outline-offset: 2px; }

.attendance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.attendance-heading { min-width: 0; }
.attendance-heading p { margin-top: 5px; color: #6b7e76; font-size: 13px; }
.attendance-back {
  display: block;
  margin: 0 0 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #547064;
  font-size: 12px;
  cursor: pointer;
}
.attendance-back:hover { color: #285f49; }

.attendance-header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.attendance-header-actions.is-full { width: 100%; }
.attendance-header-actions.is-full .attendance-month-switch { flex: 0 0 auto; }
.attendance-header-actions.is-full .attendance-timeline-legend {
  flex: 1 1 auto;
  justify-content: flex-start;
  margin: 0 0 0 24px;
  font-size: 12px;
}
.attendance-month-switch {
  display: grid;
  grid-template-columns: 34px minmax(112px, auto) 34px;
  align-items: center;
  overflow: hidden;
  border: 1px solid #d6e2dc;
  border-radius: 9px;
  background: #fff;
}
.attendance-month-switch button {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: #315f4c;
  font-size: 21px;
  cursor: pointer;
}
.attendance-month-switch button:hover { background: #f1f6f3; }
.attendance-month-switch strong { text-align: center; font-size: 13px; font-weight: 650; }

.attendance-primary, .attendance-secondary, .attendance-text-button, .attendance-error button {
  min-height: 34px;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.attendance-primary, .attendance-error button {
  border: 1px solid #315f4c;
  background: #315f4c;
  color: #fff;
}
.attendance-primary:hover, .attendance-error button:hover { background: #284f40; }
.attendance-primary:disabled, .attendance-secondary:disabled, .attendance-text-button:disabled { cursor: wait; opacity: .6; }
.attendance-secondary {
  border: 1px solid #cbdad3;
  background: #fff;
  color: #365f4e;
}
.attendance-secondary:hover { border-color: #8eaa9d; background: #f7faf8; }
.attendance-text-button { border: 0; background: transparent; color: #7a5a35; }
.attendance-text-button:hover { background: #faf5ed; }

.attendance-sync {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #d9e4df;
  border-radius: 11px;
  background: #f8fbf9;
}
.attendance-sync > div { display: flex; align-items: center; gap: 8px; min-width: 0; }
.attendance-sync strong { font-size: 13px; }
.attendance-sync small { color: #72827b; font-size: 11.5px; }
.attendance-sync-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #6e9b86; }
.attendance-sync.is-unsynced { border-color: #e7ddcb; background: #fffcf6; }
.attendance-sync.is-unsynced .attendance-sync-dot { background: #b68a4e; }

.attendance-panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid #dce7e1;
  border-radius: 14px;
  background: #fff;
}
.attendance-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.attendance-panel-heading p { margin-top: 4px; color: #778880; font-size: 11.5px; }
.attendance-loading, .attendance-empty { padding: 38px 16px; color: #798a82; text-align: center; font-size: 13px; }
.attendance-error { color: #76572f; }
.attendance-error p { margin: 7px 0 14px; font-size: 13px; }
.attendance-inline-error { margin: 0 0 14px; padding: 10px 13px; border-radius: 9px; background: #fff6e9; color: #87561f; font-size: 12px; }
.attendance-no-access { padding: 32px; color: #6f8179; }

.attendance-table-head, .attendance-table-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.35fr) repeat(7, minmax(72px, .7fr));
  align-items: center;
  gap: 8px;
}
.attendance-table-head {
  min-height: 39px;
  padding: 0 12px;
  border-radius: 8px;
  background: #f4f8f6;
  color: #65786f;
  font-size: 11.5px;
  font-weight: 600;
}
.attendance-table-row {
  width: 100%;
  min-height: 42px;
  padding: 5px 12px;
  border: 0;
  border-bottom: 1px solid #edf2ef;
  background: transparent;
  color: #344f44;
  text-align: left;
  font-size: 12.5px;
  cursor: pointer;
}
.attendance-table-row:hover { background: #f8fbf9; }
.attendance-employee-cell { display: flex; min-width: 0; align-items: center; }
.attendance-employee-cell b { overflow: hidden; text-overflow: ellipsis; color: #2a5141; font-size: 13.5px; white-space: nowrap; }
.attendance-table-row > span:not(.attendance-employee-cell) { font-size: 13.5px; }
.attendance-no-value { color: #9ba8a2; }

.attendance-detail-summary {
  display: grid;
  grid-template-columns: repeat(7, minmax(90px, 1fr));
  gap: 9px;
  margin-bottom: 16px;
}
.attendance-detail-summary span {
  display: flex;
  min-height: 70px;
  flex-direction: column;
  justify-content: center;
  padding: 12px 14px;
  border: 1px solid #dce7e1;
  border-radius: 11px;
  background: #fff;
}
.attendance-detail-summary small { color: #73847c; font-size: 11px; }
.attendance-detail-summary b { margin-top: 5px; color: #315d4b; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }

.attendance-detail-head, .attendance-detail-row {
  display: grid;
  grid-template-columns: 76px 100px 100px minmax(130px, 1fr) minmax(145px, 1fr) 90px;
  align-items: center;
  gap: 12px;
}
.attendance-detail-head {
  min-height: 39px;
  padding: 0 12px;
  border-radius: 8px;
  background: #f4f8f6;
  color: #65786f;
  font-size: 11.5px;
  font-weight: 600;
}
.attendance-detail-row { min-height: 53px; padding: 8px 12px; border-bottom: 1px solid #edf2ef; color: #40584e; font-size: 12.5px; }
.attendance-detail-row b { font-variant-numeric: tabular-nums; }
.attendance-state { color: #456858; }
.attendance-state.is-exception { color: #956536; font-weight: 600; }

.attendance-toast {
  position: fixed;
  z-index: 10050;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 15px;
  border-radius: 9px;
  background: #315f4c;
  color: #fff;
  box-shadow: 0 8px 28px rgba(33, 59, 48, .22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .18s, transform .18s;
  font-size: 13px;
}
.attendance-toast.is-error { background: #8d5d30; }
.attendance-toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .attendance-table { overflow-x: auto; }
  .attendance-table-head, .attendance-table-row { min-width: 820px; }
  .attendance-detail-table { overflow-x: auto; }
  .attendance-detail-head, .attendance-detail-row { min-width: 760px; }
  .attendance-detail-summary { grid-template-columns: repeat(4, minmax(90px, 1fr)); }
}

@media (max-width: 720px) {
  .attendance-page { padding: 18px 16px 30px; }
  .attendance-header { align-items: flex-start; flex-direction: column; gap: 13px; }
  .attendance-header-actions { width: 100%; justify-content: space-between; }
  .attendance-sync { align-items: flex-start; }
  .attendance-sync > div { align-items: flex-start; flex-wrap: wrap; }
  .attendance-sync small { width: 100%; padding-left: 16px; }
  .attendance-panel { padding: 16px; }
  .attendance-detail-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .attendance-detail-summary span { min-height: 62px; }
}

@media (max-width: 520px) {
  .attendance-page { padding: 14px 12px 24px; }
  .attendance-page h1 { font-size: 22px; }
  .attendance-heading p { display: none; }
  .attendance-header-actions { align-items: stretch; flex-direction: column; }
  .attendance-month-switch { width: 100%; grid-template-columns: 38px 1fr 38px; }
  .attendance-header-actions > .attendance-secondary { width: 100%; }
  .attendance-sync { align-items: stretch; flex-direction: column; gap: 10px; }
  .attendance-sync .attendance-primary { width: 100%; }
  .attendance-table-head { display: none; }
  .attendance-table { overflow: visible; }
  .attendance-table-body { display: grid; gap: 10px; }
  .attendance-table-row {
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    padding: 14px;
    border: 1px solid #e0e9e5;
    border-radius: 10px;
  }
  .attendance-table-row .attendance-employee-cell { grid-column: 1 / -1; padding-bottom: 7px; border-bottom: 1px solid #edf2ef; }
  .attendance-table-row > span:not(.attendance-employee-cell)::before { content: attr(data-label); display: block; margin-bottom: 3px; color: #819089; font-size: 10px; }
  .attendance-detail-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .attendance-detail-head { display: none; }
  .attendance-detail-table { overflow: visible; }
  .attendance-detail-body { display: grid; gap: 10px; }
  .attendance-detail-row {
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    padding: 14px;
    border: 1px solid #e0e9e5;
    border-radius: 10px;
  }
  .attendance-detail-row > span::before { content: attr(data-label); display: block; margin-bottom: 3px; color: #819089; font-size: 10px; font-weight: 400; }
  .attendance-toast { right: 16px; bottom: 16px; }
}

/* Read-only employee/date timeline; the monthly table keeps its existing layout.
   Background/grid (0) < today line (1) < opaque leave bars (2) < sticky header (4). */
.attendance-timeline { min-width: 0; margin-bottom: 20px; }
.attendance-timeline-scroll { width: 100%; max-width: 100%; overflow: auto; max-height: 680px; overscroll-behavior-x: contain; border-radius: 8px; scrollbar-color: #d9dfdb #f4f5f3; scrollbar-width: thin; }
/* Standard scrollbar styling is the fallback; WebKit keeps the precise 6px size. */
.attendance-timeline-scroll:hover { scrollbar-color: #c7cfca #f4f5f3; }
@supports selector(::-webkit-scrollbar) {
  .attendance-timeline-scroll, .attendance-timeline-scroll:hover { scrollbar-color: auto; scrollbar-width: auto; }
  .attendance-timeline-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
  .attendance-timeline-scroll::-webkit-scrollbar-track { background: #f4f5f3; border-radius: 999px; }
  .attendance-timeline-scroll::-webkit-scrollbar-thumb { background: #d9dfdb; border-radius: 999px; }
  .attendance-timeline-scroll::-webkit-scrollbar-thumb:hover { background: #c7cfca; }
}
.attendance-timeline-scroll:focus-visible { outline: 2px solid #739b83; outline-offset: 3px; }
.attendance-timeline-content { position: relative; isolation: isolate; width: calc(120px + var(--timeline-days-width)); background: #fff; }
.attendance-timeline-columns { position: absolute; z-index: 0; inset: 0 0 0 120px; display: flex; pointer-events: none; }
.attendance-timeline-columns > span { flex: 0 0 48px; box-sizing: border-box; border-right: 1px solid #edf0ee; }
.attendance-timeline .is-holiday { background: #fcfaf5; }
.attendance-timeline .is-weekend { background: #f7f8f6; }
.attendance-timeline-row, .attendance-timeline-header { position: relative; display: flex; height: 34px; box-sizing: border-box; border-bottom: 1px solid #edf0ee; }
.attendance-timeline-name { position: sticky; left: 0; z-index: 3; flex: 0 0 120px; box-sizing: border-box; display: flex; align-items: center; padding: 0 16px; overflow: hidden; background: #fff; border-right: 1px solid #edf0ee; color: #405a4d; font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.attendance-timeline-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attendance-timeline-header { position: sticky; top: 0; z-index: 4; height: 52px; background: #fff; }
.attendance-timeline-header .attendance-timeline-name { z-index: 5; color: #71837a; font-weight: 500; }
.attendance-timeline-dates { display: flex; width: var(--timeline-days-width); flex-shrink: 0; }
.attendance-timeline-date { position: relative; flex: 0 0 48px; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; border-right: 1px solid #edf0ee; color: #52695e; }
.attendance-timeline-date time { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; font-size: 16px; line-height: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.attendance-timeline-date > span { color: #78867e; font-size: 11px; line-height: 16px; }
.attendance-timeline-date small { margin-left: 4px; color: #66776f; font-size: 10px; }
.attendance-timeline-date.is-today time { border-radius: 50%; background: #315f4b; color: #fff; }
.attendance-timeline-date.is-today::after { position: absolute; content: ''; bottom: 0; left: 24px; width: 1px; height: 6px; background: rgb(49 95 75 / 30%); }
.attendance-timeline-today-line { position: absolute; top: 52px; bottom: 0; z-index: 1; width: 1px; background: rgb(49 95 75 / 30%); pointer-events: none; }
.attendance-timeline-track { position: relative; flex: 0 0 var(--timeline-days-width); min-width: 0; }
.attendance-page .attendance-timeline-leave, .attendance-timeline-holiday { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; box-sizing: border-box; height: 24px; margin: 0; padding: 0 6px; overflow: hidden; border: 1px solid #557565; border-left-width: 3px; border-radius: 5px; background: #e7f0eb; color: #486356; font-size: 12px; line-height: 22px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.attendance-page .attendance-timeline-leave { height: 6px; min-height: 6px; border: none; border-radius: 999px; padding: 0; background: var(--leave-color, #CBE88C); color: transparent; font-size: 0; line-height: 0; box-shadow: none; cursor: pointer; }
.attendance-page .attendance-timeline-leave:hover { background: var(--leave-color, #CBE88C); }
.attendance-page .attendance-timeline-leave:focus-visible { z-index: 3; outline: 2px solid #315f4b; outline-offset: 1px; }
.attendance-timeline-holiday-row { height: 40px; }
.attendance-timeline-holiday-row .attendance-timeline-name { color: #8a7049; }
.attendance-timeline-holiday { height: 24px; border: 0; background: #f4eee1; color: #8a7049; line-height: 24px; }
.attendance-page .attendance-timeline-note { margin: 14px 0 0; color: #7f9288; font-size: 12px; }
.attendance-table-row.is-calendar-highlight { background: #e4f0e8; box-shadow: inset 3px 0 #739b83; }
@media (max-width: 720px) {
  .attendance-timeline { padding: 12px 8px; }
  .attendance-header-actions.is-full { align-items: flex-start; flex-direction: column; }
  .attendance-header-actions.is-full .attendance-timeline-legend { margin-left: 0; }
}

.attendance-timeline-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 9px; color: #78867e; font-size: 11px; line-height: 16px; }
.attendance-timeline-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.attendance-timeline-legend i { display: inline-block; width: 18px; height: 3px; border-radius: 999px; }
