/* Attendance portal ------------------------------------------------------- */
.attendance-portal-root {
  --attendance-ink: #142239;
  --attendance-muted: #6d8191;
  --attendance-line: #dce7ed;
  --attendance-soft: #f6fafc;
  --attendance-blue: #087eae;
  --attendance-blue-dark: #075b82;
  --attendance-green: #087b5c;
  --attendance-orange: #b86d18;
  --attendance-red: #b33b3b;
  box-sizing: border-box;
  width: 100%;
  margin: 16px 0 28px;
  color: var(--attendance-ink);
  font-family: inherit;
}

.attendance-portal-root *,
.attendance-photo-modal * { box-sizing: border-box; }

.attendance-portal-heading,
.attendance-table-heading,
.attendance-staff-tools,
.attendance-period-toolbar,
.attendance-active-card,
.attendance-podium-card { min-width: 0; }

.attendance-portal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 14px;
}

.attendance-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--attendance-blue);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1.1px;
  text-transform: uppercase;
}

.attendance-portal-heading h2 {
  margin: 0;
  color: var(--attendance-ink);
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -.55px;
}

.attendance-portal-heading p {
  max-width: 680px;
  margin: 6px 0 0;
  color: var(--attendance-muted);
  font-size: 11px;
  line-height: 1.5;
}

.attendance-server-time {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 5px;
  padding: 7px 10px;
  border: 1px solid #cce3ec;
  border-radius: 999px;
  background: #f2fbfd;
  color: var(--attendance-blue-dark);
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.attendance-server-time i,
.attendance-live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #1aaa86;
  box-shadow: 0 0 0 3px #1aaa8626;
}

.attendance-period-toolbar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px;
  padding: 13px 14px;
  border: 1px solid var(--attendance-line);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 7px 22px #13395608;
}

.attendance-period-heading {
  display: grid;
  min-width: 145px;
  margin-right: 5px;
  align-self: center;
}

.attendance-period-heading .attendance-eyebrow { margin: 0 0 3px; }
.attendance-period-heading b { font-size: 11px; }

.attendance-period-toolbar label,
.attendance-search-label {
  display: grid;
  gap: 5px;
  color: #617487;
  font-size: 9px;
  font-weight: 800;
}

.attendance-period-toolbar input,
.attendance-staff-tools input {
  min-height: 35px;
  border: 1px solid #d4e1e8;
  border-radius: 8px;
  outline: none;
  background: #fbfdfe;
  color: var(--attendance-ink);
  font: inherit;
  font-size: 10px;
}

.attendance-period-toolbar input { min-width: 142px; padding: 8px 10px; }
.attendance-period-toolbar input:focus,
.attendance-staff-tools input:focus { border-color: #58b6d2; box-shadow: 0 0 0 3px #58b6d226; }

.attendance-period-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.attendance-apply-button,
.attendance-reset-button,
.attendance-refresh-button,
.attendance-retry-button {
  min-height: 35px;
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  transition: .16s ease;
}

.attendance-apply-button {
  border: 1px solid var(--attendance-blue);
  background: var(--attendance-blue);
  color: #fff;
}

.attendance-apply-button:hover { background: var(--attendance-blue-dark); border-color: var(--attendance-blue-dark); }
.attendance-reset-button,
.attendance-refresh-button,
.attendance-retry-button { border: 1px solid #cbdde6; background: #fff; color: var(--attendance-blue-dark); }
.attendance-reset-button:hover,
.attendance-refresh-button:hover,
.attendance-retry-button:hover { border-color: #80bfd3; background: #eef9fc; }

.attendance-period-label {
  align-self: center;
  margin-left: auto;
  color: var(--attendance-muted);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.attendance-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.attendance-summary-card {
  display: grid;
  gap: 4px;
  min-height: 94px;
  padding: 14px;
  border: 1px solid var(--attendance-line);
  border-radius: 12px;
  background: linear-gradient(145deg, #fff, #f8fcfd);
}

.attendance-summary-card span { color: var(--attendance-muted); font-size: 9px; font-weight: 800; }
.attendance-summary-card strong { color: var(--attendance-blue-dark); font-size: 23px; line-height: 1; letter-spacing: -.6px; }
.attendance-summary-card small { color: #8293a1; font-size: 9px; }

.attendance-table-panel,
.attendance-active-panel {
  overflow: hidden;
  border: 1px solid var(--attendance-line);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 8px 25px #153a5308;
}

.attendance-table-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px 12px;
}

.attendance-table-heading h3 { margin: 0; color: var(--attendance-ink); font-size: 13px; }
.attendance-table-heading p { margin: 4px 0 0; color: var(--attendance-muted); font-size: 9px; line-height: 1.45; }

.attendance-count-badge,
.attendance-live-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 25px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #edf7fa;
  color: var(--attendance-blue-dark);
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.attendance-live-count { background: #e7f8f1; color: var(--attendance-green); }

.attendance-table-scroll { width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.attendance-data-table { width: 100%; min-width: 820px; border-collapse: collapse; }
.attendance-data-table th,
.attendance-data-table td { padding: 11px 10px; border-top: 1px solid #e8eef2; text-align: left; vertical-align: middle; font-size: 10px; white-space: nowrap; }
.attendance-data-table th { color: #718596; font-size: 8px; font-weight: 900; letter-spacing: .65px; text-transform: uppercase; background: #fbfdfe; }
.attendance-data-table td b,
.attendance-data-table td small { display: block; }
.attendance-data-table td b { color: #1d3b51; font-size: 10px; }
.attendance-data-table td small { margin-top: 3px; color: #81929f; font-size: 8px; font-weight: 600; }
.attendance-data-table tbody tr:hover { background: #f8fcfd; }
.attendance-data-table .is-active-row { background: #f3fcf8; }

.attendance-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 900;
}

.attendance-status.is-ok { background: #e8f8f1; color: var(--attendance-green); }
.attendance-status.is-late { background: #fff2e6; color: var(--attendance-orange); }
.attendance-status.is-neutral { background: #eef3f6; color: #657b8b; }

.attendance-photo-group { display: flex; align-items: center; gap: 5px; }
.attendance-photo-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 31px;
  border: 1px solid #cfe1e8;
  border-radius: 7px;
  padding: 3px 6px 3px 3px;
  background: #fff;
  color: var(--attendance-blue-dark);
  cursor: pointer;
  font: inherit;
  font-size: 8px;
  font-weight: 800;
}

.attendance-photo-button:hover { border-color: #75bfd4; background: #effafe; }
.attendance-photo-button:disabled { cursor: not-allowed; opacity: .6; }
.attendance-photo-button img { width: 25px; height: 25px; border-radius: 5px; object-fit: cover; background: #edf3f6; }
.attendance-no-photo { color: #9aaab5; font-size: 10px; }

.attendance-score-cell strong { display: inline !important; color: var(--attendance-blue-dark) !important; font-size: 14px !important; }
.attendance-score-cell small { display: inline !important; margin-left: 2px !important; }
.attendance-rank-badge { display: inline-flex; min-width: 36px; justify-content: center; padding: 5px 7px; border-radius: 7px; background: #eef5f7; color: #587285; font-size: 9px; font-weight: 900; }
.attendance-rank-row.rank-1 .attendance-rank-badge { background: #fff1be; color: #8c6610; }
.attendance-rank-row.rank-2 .attendance-rank-badge { background: #e8edf0; color: #596d79; }
.attendance-rank-row.rank-3 .attendance-rank-badge { background: #f8e5d5; color: #98603b; }

.attendance-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.attendance-podium-card {
  display: grid;
  gap: 5px;
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--attendance-line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 7px 22px #153a5307;
}

.attendance-podium-card.rank-1 { border-color: #edd185; background: linear-gradient(145deg, #fffdf3, #fff9dc); }
.attendance-podium-card.rank-2 { background: linear-gradient(145deg, #fff, #f5f8f9); }
.attendance-podium-card.rank-3 { border-color: #ead0bd; background: linear-gradient(145deg, #fffaf6, #fff2e8); }
.attendance-podium-rank { color: var(--attendance-orange); font-size: 10px; font-weight: 900; }
.attendance-podium-card strong { overflow: hidden; color: #1d3b51; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.attendance-podium-card small { overflow: hidden; color: var(--attendance-muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.attendance-podium-card b { color: var(--attendance-blue-dark); font-size: 11px; }

.attendance-active-panel { margin: 14px 0; }
.attendance-active-empty { margin: 0; padding: 19px 16px; color: var(--attendance-muted); font-size: 10px; }
.attendance-active-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 9px; padding: 0 12px 13px; }
.attendance-active-card { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 10px; border: 1px solid #dcece6; border-radius: 10px; background: #f8fdfb; }
.attendance-active-identity { display: flex; align-items: center; flex: 1 1 auto; gap: 8px; min-width: 0; }
.attendance-active-avatar { display: grid; flex: 0 0 31px; width: 31px; height: 31px; place-items: center; border-radius: 50%; background: #daf2e9; color: var(--attendance-green); font-size: 12px; font-weight: 900; }
.attendance-active-identity strong,
.attendance-active-identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attendance-active-identity strong { color: #1d3b51; font-size: 10px; }
.attendance-active-identity small { margin-top: 2px; color: var(--attendance-muted); font-size: 8px; }
.attendance-active-identity .attendance-phone { color: #8296a2; }
.attendance-active-time { display: grid; position: relative; grid-template-columns: 7px auto; gap: 2px 5px; align-items: center; flex: 0 0 auto; }
.attendance-active-time .attendance-live-dot { grid-row: span 2; width: 6px; height: 6px; box-shadow: 0 0 0 2px #1aaa8626; }
.attendance-active-time b { color: var(--attendance-green); font-size: 10px; }
.attendance-active-time small { grid-column: 2; color: var(--attendance-muted); font-size: 8px; }
.attendance-active-card > .attendance-photo-button { flex: 0 0 auto; }

.attendance-staff-tools { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin: 0 0 13px; }
.attendance-search-label { flex: 1 1 280px; max-width: 440px; }
.attendance-staff-tools input { width: 100%; padding: 8px 10px; }
.attendance-refresh-button { flex: 0 0 auto; }

.attendance-loading-panel,
.attendance-error-panel,
.attendance-empty-panel {
  display: grid;
  justify-items: center;
  gap: 7px;
  min-height: 125px;
  padding: 30px 18px;
  border: 1px solid var(--attendance-line);
  border-radius: 12px;
  background: #fff;
  text-align: center;
}

.attendance-loading-panel { grid-template-columns: auto auto; justify-content: center; align-content: center; color: var(--attendance-muted); font-size: 10px; }
.attendance-spinner { width: 16px; height: 16px; border: 2px solid #c8e3eb; border-top-color: var(--attendance-blue); border-radius: 50%; animation: attendance-spin .8s linear infinite; }
@keyframes attendance-spin { to { transform: rotate(360deg); } }
.attendance-error-panel { border-color: #f0cccc; background: #fff7f7; color: var(--attendance-red); }
.attendance-error-panel strong { font-size: 11px; }
.attendance-error-panel p { max-width: 520px; margin: 0; font-size: 10px; line-height: 1.5; }
.attendance-empty-panel { color: var(--attendance-muted); }
.attendance-empty-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: #e8f7f1; color: var(--attendance-green); font-size: 16px; font-weight: 900; }
.attendance-empty-panel strong { color: #405c6c; font-size: 11px; }
.attendance-empty-panel p { margin: 0; font-size: 10px; }
.attendance-inline-message { margin: 0 0 12px; padding: 9px 11px; border-radius: 8px; font-size: 10px; font-weight: 700; }
.attendance-inline-message.error { border: 1px solid #efcaca; background: #fff5f5; color: var(--attendance-red); }
.attendance-inline-message.success { border: 1px solid #bde3d5; background: #effaf6; color: var(--attendance-green); }
.attendance-retry-button { justify-self: center; margin: 12px auto 0; }

.attendance-photo-modal[hidden] { display: none; }
.attendance-photo-modal { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; padding: 18px; }
.attendance-photo-backdrop { position: absolute; inset: 0; background: #08243acc; backdrop-filter: blur(2px); }
.attendance-photo-dialog { position: relative; z-index: 1; width: min(680px, 100%); max-height: calc(100vh - 36px); overflow: auto; padding: 18px; border: 1px solid #ffffff35; border-radius: 15px; background: #fff; box-shadow: 0 25px 70px #03162470; }
.attendance-photo-dialog h2 { margin: 0 38px 12px 0; color: var(--attendance-ink); font-size: 15px; }
.attendance-photo-close { position: absolute; top: 9px; right: 10px; display: grid; width: 31px; height: 31px; place-items: center; border: 1px solid #d8e4ea; border-radius: 50%; background: #fff; color: #526c7d; cursor: pointer; font-size: 21px; line-height: 1; }
.attendance-photo-close:hover { border-color: #87c6d9; color: var(--attendance-blue-dark); }
.attendance-photo-preview { display: block; width: 100%; max-height: 65vh; border-radius: 9px; object-fit: contain; background: #edf3f6; }
.attendance-photo-caption { margin: 10px 0 0; color: var(--attendance-muted); font-size: 10px; }
.attendance-modal-open { overflow: hidden; }

@media (max-width: 850px) {
  .attendance-period-heading { min-width: 100%; }
  .attendance-period-label { width: 100%; margin: 0; }
  .attendance-staff-tools { align-items: stretch; flex-direction: column; }
  .attendance-search-label { max-width: none; }
  .attendance-refresh-button { align-self: flex-start; }
}

@media (max-width: 620px) {
  .attendance-portal-root { margin-top: 12px; }
  .attendance-portal-heading { flex-direction: column; gap: 9px; }
  .attendance-server-time { align-self: flex-start; }
  .attendance-summary-grid,
  .attendance-podium { grid-template-columns: 1fr; }
  .attendance-summary-card { min-height: 76px; }
  .attendance-period-toolbar { align-items: stretch; flex-direction: column; }
  .attendance-period-toolbar label { width: 100%; }
  .attendance-period-toolbar input { width: 100%; }
  .attendance-period-actions { width: 100%; }
  .attendance-period-actions button { flex: 1 1 0; }
  .attendance-table-heading { align-items: flex-start; }
  .attendance-active-list { grid-template-columns: 1fr; }
  .attendance-photo-dialog { padding: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .attendance-spinner { animation: none; }
  .attendance-apply-button,
  .attendance-reset-button,
  .attendance-refresh-button,
  .attendance-retry-button,
  .attendance-photo-button { transition: none; }
}
