:root {
  font-family: Arial, sans-serif;
  color: #102033;
  background: #edf2f7;
}

body {
  margin: 0;
}

.hidden {
  display: none !important;
}

body.locked {
  background: #edf2f7;
}

.shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}

.rail {
  background: #152033;
  color: #fff;
  padding: 18px;
}

body.locked .rail,
body.locked .topbar,
body.locked .panel,
body.locked #logoutBtn {
  display: none;
}

body.locked .shell {
  display: block;
  min-height: 100vh;
}

body.locked .content {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

body.locked #loginPanel {
  display: block;
  width: min(520px, 100%);
  margin: 0;
}

body.unlocked #loginPanel {
  display: none;
}

.rail h1 {
  font-size: 22px;
  margin: 0 0 22px;
}

.nav,
button {
  border: 0;
  border-radius: 8px;
  padding: 10px 13px;
  font-weight: 700;
  cursor: pointer;
}

.nav {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
  background: transparent;
  color: #d8e2ef;
  border: 1px solid transparent;
}

.nav.active {
  color: #fff;
  background: #24324a;
  border-color: #93c5fd;
}

.content {
  padding: 18px;
  overflow: auto;
}

.topbar,
.section-title,
.actions,
.row-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.topbar span,
.muted,
td small {
  color: #64748b;
  display: block;
  font-size: 13px;
}

.session-timer {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.card {
  background: #fff;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
}

.login-card {
  background: #f8fafc;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

h2,
p {
  margin-top: 0;
}

.grid {
  display: grid;
  gap: 10px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.labelled-grid {
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.filters {
  align-items: center;
  margin-bottom: 12px;
}

.date-stepper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

input,
select {
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 11px;
  font-size: 14px;
  background: #fff;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-weight: 700;
}

.check-row input {
  width: auto;
}

.bulk-note {
  align-self: center;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

button {
  background: #2563eb;
  color: #fff;
}

button.secondary {
  background: #475569;
}

textarea {
  min-height: 92px;
  resize: vertical;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 11px;
  font-size: 14px;
  font-family: inherit;
}

.wide-field {
  grid-column: span 2;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.54);
}

.modal-card {
  width: min(1180px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.26);
}

.staff-list,
.batch-list,
.compact-list {
  display: grid;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
}

.batch-list {
  margin-top: 12px;
  max-height: 180px;
}

.staff-row,
.batch-row,
.compact-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.compact-row span {
  color: #64748b;
  display: block;
  font-size: 13px;
}

.analysis-cards,
.analysis-grid {
  margin-top: 12px;
}

.analysis-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.analysis-card {
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

.analysis-card label {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  display: block;
  margin-bottom: 6px;
}

.analysis-card strong {
  font-size: 24px;
  color: #0f172a;
}

.analysis-card span {
  display: block;
  margin-top: 6px;
  color: #475569;
  font-size: 12px;
}

.staff-meta,
.batch-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.staff-meta span,
.batch-meta span {
  border: 1px solid #dbe4ef;
  border-radius: 6px;
  padding: 4px 7px;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.row-actions {
  justify-content: flex-end;
}

.camera-box {
  position: relative;
  width: 760px;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  background: #020617;
  border-radius: 8px;
  overflow: hidden;
  margin: 14px 0;
}

video,
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

video {
  transform: scaleX(-1);
}

canvas {
  pointer-events: none;
}

.face-guide {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  pointer-events: none;
  perspective: 900px;
}

.face-halo {
  position: relative;
  width: min(54%, 280px);
  height: min(82%, 360px);
  border: 2px solid rgba(125, 211, 252, 0.85);
  border-radius: 48% 48% 44% 44%;
  box-shadow:
    0 0 28px rgba(14, 165, 233, 0.36),
    inset 0 0 28px rgba(14, 165, 233, 0.18);
  transform: rotateX(8deg);
}

.face-halo::before,
.face-halo::after {
  content: '';
  position: absolute;
  inset: 12%;
  border-radius: inherit;
  border: 1px solid rgba(186, 230, 253, 0.45);
}

.face-halo::after {
  inset: 24% 18%;
  border-color: rgba(34, 197, 94, 0.38);
}

.scan-line {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 2px;
  top: 18%;
  background: linear-gradient(90deg, transparent, #22d3ee, transparent);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.9);
  animation: scanSweep 1.8s ease-in-out infinite;
}

.face-grid {
  position: absolute;
  background: rgba(125, 211, 252, 0.3);
}

.face-grid.v1,
.face-grid.v2 {
  top: 13%;
  bottom: 13%;
  width: 1px;
}

.face-grid.v1 {
  left: 38%;
}

.face-grid.v2 {
  right: 38%;
}

.face-grid.h1,
.face-grid.h2 {
  left: 18%;
  right: 18%;
  height: 1px;
}

.face-grid.h1 {
  top: 39%;
}

.face-grid.h2 {
  bottom: 32%;
}

@keyframes scanSweep {
  0%, 100% {
    top: 18%;
    opacity: 0.55;
  }
  50% {
    top: 78%;
    opacity: 1;
  }
}

.instruction,
.status,
#toast {
  padding: 10px 12px;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 700;
}

.table-wrap {
  max-height: 520px;
  overflow: auto;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 8px 9px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eff6ff;
}

tr.needs-review td {
  background: #fff7ed;
}

.question-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #f97316;
  color: #fff;
  font-weight: 900;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.tag.good {
  background: #dcfce7;
  color: #166534;
}

th input[type='checkbox'],
td input[type='checkbox'] {
  width: auto;
  min-width: 0;
}

td input,
td select {
  min-width: 140px;
  padding: 7px 8px;
}

.inline-punch-row,
.inline-punch-add {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.inline-punch-actions {
  display: inline-flex;
  gap: 6px;
}

.inline-punch-add {
  grid-template-columns: 70px 110px auto;
}

.inline-punch-edit {
  display: inline-grid;
  grid-template-columns: 70px auto auto auto;
  gap: 6px;
  align-items: center;
}

.icon-button {
  min-width: 34px;
  padding: 7px 9px;
  line-height: 1;
}

.pen-left {
  transform: scaleX(-1);
}

.icon-button.danger {
  background: #dc2626;
}

.punch-summary-stack {
  display: grid;
  gap: 4px;
  white-space: normal;
  min-width: 140px;
}

.live-punch-modal-card {
  width: min(920px, 100%);
}

.live-punch-modal-body {
  display: grid;
  gap: 12px;
}

.live-punch-modal-section {
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.live-punch-highlight {
  background: #eff6ff;
  border-color: #93c5fd;
}

.live-punch-highlight strong {
  display: block;
  font-size: 20px;
  color: #1d4ed8;
}

.live-punch-highlight span {
  display: block;
  margin-top: 4px;
  color: #334155;
  font-weight: 700;
}

.inline-punch-add-modal {
  display: grid;
  grid-template-columns: 90px auto auto;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.meridiem-time {
  display: inline-grid;
  grid-template-columns: 70px 70px 74px;
  gap: 6px;
  align-items: center;
}

.meridiem-time select {
  min-width: 0;
}

.inline-punch-row input,
.inline-punch-row select,
.inline-punch-add input,
.inline-punch-add select {
  min-width: 0;
}

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: none;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 12px;
  }

  .rail h1 {
    font-size: 18px;
    margin-bottom: 10px;
  }

  .nav {
    display: inline-block;
    width: auto;
    margin: 0 6px 6px 0;
    padding: 8px 10px;
    font-size: 13px;
  }

  .content {
    padding: 10px;
  }

  .topbar,
  .section-title,
  .actions,
  .staff-row,
  .batch-row,
  .compact-row {
    align-items: stretch;
    flex-direction: column;
  }

  .card {
    padding: 12px;
    margin-top: 10px;
  }

  h2 {
    font-size: 18px;
  }

  .grid.two,
  .grid.four {
    grid-template-columns: 1fr;
  }

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

  .staff-row,
  .batch-row,
  .compact-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .row-actions,
  .actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .camera-box {
    width: 100%;
    aspect-ratio: 3 / 4;
  }

  .table-wrap {
    max-height: 65vh;
  }

  th,
  td {
    padding: 8px;
  }

  td input,
  td select {
    min-width: 150px;
  }

  .inline-punch-row,
  .inline-punch-add {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
