:root {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #152033;
  background: #eef2f7;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  padding: 10px 16px;
  cursor: pointer;
}
button:hover { filter: brightness(.97); }
button:disabled { opacity: .55; cursor: wait; }
button.primary {
  background: #1456a0;
  color: white;
  border-color: #1456a0;
  font-weight: 700;
}
.page { max-width: 1440px; margin: 0 auto; padding: 20px; }
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}
.hero h1 { margin: 0 0 5px; font-size: 28px; }
.hero p { margin: 0; color: #62708a; }
.card {
  background: #fff;
  border: 1px solid #dde4ee;
  border-radius: 15px;
  box-shadow: 0 8px 30px rgba(39, 52, 78, .06);
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 13px;
  padding: 15px;
  margin-bottom: 12px;
}
.toolbar label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}
.toolbar input {
  min-width: 170px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  padding: 9px 11px;
}
.legend { display: flex; flex-wrap: wrap; gap: 7px; margin-left: auto; }
.chip {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
}
.chip.absent { background: #6b7280; }
.chip.late { background: #c62828; }
.chip.overtime { background: #1565c0; }
.chip.late_overtime { background: #6a1b9a; }
.status {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 13px 15px;
  margin-bottom: 12px;
  color: #44516a;
}
.table-card { overflow: hidden; }
.summary {
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e4e9f1;
  font-weight: 800;
}
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1050px; }
th {
  position: sticky;
  top: 0;
  background: #f7f9fc;
  color: #38455d;
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid #dfe6ef;
  white-space: nowrap;
}
td {
  padding: 11px 10px;
  border-bottom: 1px solid #edf1f6;
  white-space: nowrap;
}
tbody tr:hover td { filter: brightness(.97); }
td.center { text-align: center; }
td.status-cell {
  color: #fff;
  font-weight: 800;
  border-radius: 6px;
}
td.absent { background: #6b7280; color: #fff; font-weight: 800; }
td.late { background: #c62828; color: #fff; font-weight: 800; }
td.overtime { background: #1565c0; color: #fff; font-weight: 800; }
td.late_overtime { background: #6a1b9a; color: #fff; font-weight: 800; }
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}
.badge.normal { background: #e8f5e9; color: #176b2c; }
.badge.absent { background: #6b7280; color: #fff; }
.badge.late { background: #c62828; color: #fff; }
.badge.overtime { background: #1565c0; color: #fff; }
.badge.late_overtime { background: #6a1b9a; color: #fff; }
@media (max-width: 850px) {
  .hero { align-items: stretch; flex-direction: column; }
  .status { grid-template-columns: 1fr; }
  .legend { margin-left: 0; width: 100%; }
}

.mobile-view { display: none; }

.attendance-cards {
  padding: 12px;
  gap: 12px;
}

.attendance-card {
  background: #ffffff;
  border: 1px solid #dfe6ef;
  border-left: 6px solid #94a3b8;
  border-radius: 14px;
  padding: 13px;
  box-shadow: 0 4px 16px rgba(39, 52, 78, .07);
}

.attendance-card.normal { border-left-color: #2e7d32; }
.attendance-card.absent { border-left-color: #6b7280; }
.attendance-card.late { border-left-color: #c62828; }
.attendance-card.overtime { border-left-color: #1565c0; }
.attendance-card.late_overtime { border-left-color: #6a1b9a; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid #e8edf4;
}

.card-head > div {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.card-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.employee-no {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 30px;
  border-radius: 8px;
  background: #eef3f8;
  font-weight: 900;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card-grid > div {
  display: grid;
  gap: 4px;
}

.card-grid .wide {
  grid-column: 1 / -1;
}

.card-grid .label {
  color: #6b778c;
  font-size: 12px;
  font-weight: 700;
}

.text-absent { color: #6b7280; }
.text-late { color: #c62828; }
.text-overtime { color: #1565c0; }

@media (max-width: 760px) {
  .page { padding: 10px; }
  .hero h1 { font-size: 22px; }
  .hero .primary { width: 100%; }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .toolbar label,
  .toolbar input,
  .toolbar button {
    width: 100%;
  }

  .toolbar input {
    min-width: 0;
  }

  .legend {
    width: 100%;
    margin-left: 0;
  }

  .status {
    grid-template-columns: 1fr;
    font-size: 13px;
  }

  .desktop-view { display: none; }
  .mobile-view { display: grid; }

  .summary {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
  }
}


/* v1.6 早退状态 */
.chip.early_leave,
.badge.early_leave,
td.early_leave {
  background: #D97706;
  color: #FFFFFF;
  font-weight: 800;
}

.chip.late_early,
.badge.late_early,
td.late_early {
  background: #B45309;
  color: #FFFFFF;
  font-weight: 800;
}

.attendance-card.early_leave { border-left-color: #D97706; }
.attendance-card.late_early { border-left-color: #B45309; }

.text-early {
  color: #C2410C;
  font-weight: 900;
}

@media (max-width: 760px) {
  .attendance-card {
    padding: 11px 12px;
  }

  .card-head {
    padding-bottom: 8px;
    margin-bottom: 8px;
  }

  .card-grid {
    grid-template-columns: 1fr 1fr;
    gap: 9px 12px;
  }

  .card-grid .wide {
    grid-column: auto;
  }

  .card-grid .label {
    font-size: 11px;
  }

  .card-grid strong {
    font-size: 15px;
  }
}


/* v1.9 快捷日期按钮 */
.quick-date-group {
  display: grid;
  gap: 6px;
}

.quick-date-label {
  font-size: 13px;
  font-weight: 700;
}

.quick-date-buttons {
  display: flex;
  gap: 7px;
}

.quick-date-btn {
  min-width: 64px;
  padding: 9px 12px;
  font-weight: 800;
}

.quick-date-btn.active {
  background: #1456A0;
  color: #FFFFFF;
  border-color: #1456A0;
}

@media (max-width: 760px) {
  .quick-date-group {
    width: 100%;
  }

  .quick-date-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .quick-date-btn {
    width: 100%;
  }
}


/* v1.17 顶部操作按钮 */
.hero-actions {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.hero-actions button {
  min-width: 170px;
  min-height: 48px;
  font-weight: 800;
}

button.secondary-action {
  background: #0F766E;
  color: #FFFFFF;
  border-color: #0F766E;
}

/* v1.17 手机版员工头像 */
.employee-avatar-wrap {
  display: none;
}

@media (max-width: 850px) {
  .hero-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .hero-actions button {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .attendance-card {
    position: relative;
    min-height: 176px;
    overflow: hidden;
  }

  .attendance-card .card-grid {
    padding-right: 102px;
  }

  .employee-avatar-wrap {
    position: absolute;
    right: 14px;
    top: 58px;
    width: 82px;
    height: 82px;
    display: block;
  }

  .employee-avatar,
  .employee-avatar-fallback {
    width: 82px;
    height: 82px;
    border-radius: 50%;
    border: 3px solid #FFFFFF;
    box-shadow: 0 3px 12px rgba(15, 23, 42, .16);
    background: #E8EEF6;
  }

  .employee-avatar {
    object-fit: cover;
    object-position: center;
  }

  .employee-avatar-fallback {
    place-items: center;
    color: #52637B;
    font-size: 15px;
    font-weight: 900;
    text-align: center;
  }
}

@media (max-width: 420px) {
  .hero-actions {
    grid-template-columns: 1fr;
  }

  .attendance-card .card-grid {
    padding-right: 92px;
  }

  .employee-avatar-wrap,
  .employee-avatar,
  .employee-avatar-fallback {
    width: 74px;
    height: 74px;
  }
}


/* v1.18 实时头像与第三个操作按钮 */
button.photo-action {
  background: #7C3AED;
  color: #FFFFFF;
  border-color: #7C3AED;
}

@media (max-width: 850px) {
  .hero-actions {
    grid-template-columns: 1fr 1fr;
  }
  .hero-actions .photo-action {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .employee-avatar-wrap,
  .employee-avatar,
  .employee-avatar-fallback {
    width: 88px;
    height: 88px;
  }
  .employee-avatar-wrap {
    right: 13px;
    top: 57px;
  }
}


/* =========================================================
   v1.20 - Desktop real photo + strict responsive separation
   ========================================================= */

/* Desktop is the default layout. */
.desktop-view {
  display: block !important;
}

.mobile-view,
.mobile-view.attendance-cards,
#attendanceCards {
  display: none !important;
}

/* Desktop employee photos */
.desktop-photo-cell {
  width: 64px;
  min-width: 64px;
}

.desktop-avatar-wrap,
.desktop-avatar,
.desktop-avatar-fallback {
  width: 44px;
  height: 44px;
}

.desktop-avatar-wrap {
  margin: 0 auto;
  position: relative;
}

.desktop-avatar,
.desktop-avatar-fallback {
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 9px rgba(15, 23, 42, .16);
  background: #E8EEF6;
}

.desktop-avatar {
  display: block;
  object-fit: cover;
  object-position: center;
}

.desktop-avatar-fallback {
  place-items: center;
  color: #52637B;
  font-size: 10px;
  font-weight: 900;
  text-align: center;
  overflow: hidden;
}

.employee-name-cell {
  font-weight: 650;
}

/* Mobile: hide the desktop table and show cards only. */
@media (max-width: 760px) {
  .desktop-view,
  .desktop-view.table-wrap {
    display: none !important;
  }

  .mobile-view.attendance-cards,
  #attendanceCards {
    display: grid !important;
  }
}

/* Desktop/tablet wider than 760px: cards must never appear below the table. */
@media (min-width: 761px) {
  .desktop-view,
  .desktop-view.table-wrap {
    display: block !important;
  }

  .mobile-view,
  .mobile-view.attendance-cards,
  #attendanceCards {
    display: none !important;
  }
}


/* v1.29 employee visibility */
button.employee-action {
  background: #334155;
  color: #fff;
  border-color: #334155;
  font-weight: 700;
}

.employee-manage-panel {
  margin-bottom: 12px;
  padding: 14px;
}

.employee-manage-panel[hidden] { display: none !important; }

.employee-manage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e4e9f1;
}

.employee-manage-head > div {
  display: grid;
  gap: 4px;
}

.employee-manage-head span {
  color: #64748b;
  font-size: 13px;
}

.employee-manage-list {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  max-height: 520px;
  overflow: auto;
}

.employee-manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  padding: 10px 12px;
  background: #fff;
}

.employee-manage-row.is-hidden {
  background: #f8fafc;
  opacity: .78;
}

.employee-manage-info {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.employee-manage-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

.employee-manage-info span,
.employee-manage-loading {
  color: #64748b;
  font-size: 12px;
}

.hide-employee-btn {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
  font-weight: 800;
}

.show-employee-btn {
  background: #ecfdf5;
  border-color: #86efac;
  color: #166534;
  font-weight: 800;
}

@media (max-width: 760px) {
  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .employee-manage-row {
    align-items: stretch;
    flex-direction: column;
  }
  .employee-manage-row button { width: 100%; }
}
