:root {
  --bg: #eef3f7;
  --card: #ffffff;
  --primary: #0c6f7d;
  --primary-dark: #084c57;
  --accent: #1aa1a6;
  --accent-soft: #dff4f3;
  --text: #122025;
  --muted: #6b7f86;
  --danger: #e45757;
  --shadow: 0 16px 40px rgba(13, 40, 55, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, #f7fbff, #e7f1f6 45%, #d7edf2 100%);
}

.kiosk-body, .kiosk-app {
  min-height: 100vh;
}

.card {
  background: var(--card);
  padding: 24px;
  max-width: 520px;
  margin: 60px auto;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.card.wide { max-width: 960px; }

h1, h2 { margin-top: 0; }
label { display: block; margin: 12px 0 6px; }
input, select, button {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #ccd4d2;
}
button {
  background: var(--primary);
  color: #fff;
  border: none;
  margin-top: 12px;
  cursor: pointer;
}
button.secondary { background: #889591; }

.alert { background: #ffe7e0; padding: 8px; border-radius: 8px; margin-bottom: 12px; }
.alert.success { background: #e4f7f0; }

.hidden { display: none; }
.muted { color: var(--muted); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: linear-gradient(90deg, #0c6f7d, #12959b);
  color: #fff;
  border-bottom: none;
}
.status {
  display: flex;
  align-items: center;
  gap: 10px;
}
.th-menu .btn.ghost {
  align-self: center;
}

.status .badge {
  display: inline-block;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  margin-left: 8px;
}
.status .badge.online { background: rgba(255, 255, 255, 0.35); }

.kiosk-top .brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-mark {
  font-size: 12px;
  letter-spacing: 4px;
}
.brand-title {
  font-size: 18px;
  font-weight: 600;
}

.kiosk-shell {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  padding: 24px;
}

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

.stage-header h1 {
  font-size: 28px;
  margin: 0 0 6px;
}
.stage-header h2 { margin: 0 0 6px; }
.stage-header.centered {
  text-align: center;
  margin: 26px auto 10px;
  width: 100%;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 4px;
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 6px;
}

.punch-actions {
  display: flex;
  gap: 16px;
  margin: 16px 0 24px;
  align-items: center;
  justify-content: center;
}
.punch-btn {
  flex: 0 0 auto;
  width: 170px;
  height: 170px;
  padding: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #19b6b1, #0c6f7d);
  color: #fff;
  border: 2px solid rgba(12, 111, 125, 0.25);
  font-size: 18px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.2s ease, opacity 0.25s ease, max-width 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.punch-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.punch-label {
  font-size: 22px;
  letter-spacing: 2px;
}
.punch-btn:hover { transform: translateY(-2px); }
.punch-btn.active {
  background: linear-gradient(135deg, #19b6b1, #0c6f7d);
  color: #fff;
  border-color: rgba(12, 111, 125, 0.6);
}
.punch-btn[data-punch="OUT"] {
  background: linear-gradient(135deg, #f08b5b, #c65b2b);
  border-color: rgba(198, 91, 43, 0.35);
}
.punch-btn[data-punch="OUT"].active {
  background: linear-gradient(135deg, #f08b5b, #c65b2b);
  border-color: rgba(198, 91, 43, 0.7);
}
.punch-actions.compact .punch-btn:not(.active):not(.back-btn) {
  opacity: 0;
  max-width: 0;
  width: 0;
  flex: 0;
  padding: 0;
  border: none;
  margin: 0;
  pointer-events: none;
}
.back-btn {
  background: #f0f4f7;
  color: var(--primary-dark);
  border-color: rgba(12, 111, 125, 0.2);
}
.back-btn .icon svg { width: 22px; height: 22px; }
.punch-btn .icon svg {
  width: 28px;
  height: 28px;
}

.method-stage {
  background: #ffffff;
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
}
.method-stage.show {
  opacity: 1;
  transform: translateY(0);
  animation: floatIn 0.4s ease;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.method-grid button {
  background: #f5fbfb;
  color: var(--primary-dark);
  border: 1px solid rgba(12, 111, 125, 0.2);
  border-radius: 14px;
  padding: 18px;
  margin-top: 0;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.method-grid button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.method-grid button svg {
  width: 42px;
  height: 42px;
}

.panel {
  background: #f7fbfb;
  padding: 8px;
  border-radius: 14px;
  margin-top: 11px;
  border: 2px solid transparent;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
#facePanel {
  border-color: rgba(12, 111, 125, 0.12);
}
.kiosk-app[data-punch="IN"] #facePanel {
  border-color: rgba(26, 161, 166, 0.45);
  box-shadow: 0 12px 26px rgba(26, 161, 166, 0.22);
}
.kiosk-app[data-punch="OUT"] #facePanel {
  border-color: rgba(240, 139, 91, 0.45);
  box-shadow: 0 12px 26px rgba(240, 139, 91, 0.22);
}
.face-frame {
  width: 320px;
  height: 320px;
  margin: 0 auto 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #0a1418;
  box-shadow: 0 14px 30px rgba(12, 111, 125, 0.2);
  position: relative;
  transition: box-shadow 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
}
.kiosk-app[data-punch="IN"] .face-frame {
  box-shadow: 0 16px 30px rgba(26, 161, 166, 0.28);
}
.kiosk-app[data-punch="OUT"] .face-frame {
  box-shadow: 0 16px 30px rgba(240, 139, 91, 0.28);
}
.face-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.kiosk-app .face-frame video {
  transform: scaleX(-1);
}
.face-frame.scanning {
  box-shadow:
    0 0 0 4px rgba(26, 161, 166, 0.35),
    0 0 30px rgba(26, 161, 166, 0.55);
  animation: facePulse 1.4s ease-in-out infinite;
}
.face-frame.scanning::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(26,161,166,0.35), transparent 60%);
  opacity: 0.8;
  animation: faceFlash 1.6s ease-in-out infinite;
}
.face-frame.success {
  transform: scale(0.98);
  opacity: 0.15;
}
.face-frame.success video {
  opacity: 0.05;
}
.face-frame.hidden-frame {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}
.face-success {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  color: #0c6f7d;
  background: rgba(255,255,255,0.9);
  text-align: center;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.face-success.show {
  opacity: 1;
}
.face-notice {
  margin: 10px auto 4px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: #0c6f7d;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.face-notice.hidden {
  opacity: 0;
  transform: translateY(-6px);
}

@keyframes facePulse {
  0% { box-shadow: 0 0 0 3px rgba(26,161,166,0.2), 0 0 16px rgba(26,161,166,0.35); }
  50% { box-shadow: 0 0 0 8px rgba(26,161,166,0.45), 0 0 30px rgba(26,161,166,0.65); }
  100% { box-shadow: 0 0 0 3px rgba(26,161,166,0.2), 0 0 16px rgba(26,161,166,0.35); }
}

@keyframes faceFlash {
  0% { opacity: 0.2; }
  50% { opacity: 0.8; }
  100% { opacity: 0.2; }
}
.panel:not(.hidden) {
  animation: floatIn 0.4s ease;
}

.pin-display {
  height: 52px;
  border: 1px solid rgba(12, 111, 125, 0.2);
  border-radius: 12px;
  margin-bottom: 14px;
  padding: 12px;
  font-size: 20px;
  letter-spacing: 6px;
  text-align: center;
  background: #fff;
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.pin-pad button {
  width: 80px;
  height: 80px;
  border-radius: 999px;
  margin: 0 auto;
  background: #ffffff;
  color: var(--primary);
  border: 1px solid rgba(12, 111, 125, 0.2);
  font-size: 22px;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(12, 111, 125, 0.1);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  line-height: 1.1;
}
.pin-pad button small {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--muted);
}

.video-wrap, #faceVideo {
  width: 100%;
  max-height: 320px;
  background: #111;
  border-radius: 8px;
}

#faceVideo { width: 100%; }

.punch-card {
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  box-shadow: var(--shadow);
}
.kiosk-confirm {
  margin-top: 8px;
}
.employee-name {
  margin-top: 0;
  margin-bottom: 6px;
}
.punch-result {
  margin-top: 4px;
}

.employee-name {
  font-size: 24px;
  margin-bottom: 12px;
}

.employee-photo img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
}
.confirm-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 700;
  margin: 0 auto;
}

.punch-result {
  font-size: 28px;
  margin-top: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  border-bottom: 1px solid #e5e5e5;
  padding: 8px;
}

.inline { display: inline; }
.row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.btn { display: inline-block; padding: 10px 12px; background: var(--primary); color: #fff; text-decoration: none; border-radius: 8px; border: none; }
.btn.secondary { background: #889591; }
.btn.primary { background: var(--primary); }
.btn.ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.45); }
.hidden { display: none; }
.action-row { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
.kiosk-confirm { display: flex; flex-direction: column; gap: 16px; }
.kiosk-stage { display: flex; flex-direction: column; gap: 12px; }
.kiosk-confirm .btn.ghost { color: var(--primary); border-color: rgba(12,111,125,0.3); }
.company-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}
.company-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-direction: row;
  background: #f4f8fa;
  border: 1px solid rgba(12, 111, 125, 0.15);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--primary-dark);
  font-weight: 600;
}
.company-item input {
  width: 16px;
  height: 16px;
  order: 0;
}
.company-item span {
  order: 1;
}

.enroll-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

@media (max-width: 900px) {
  .face-frame { width: 260px; height: 260px; }
  .card.wide { margin: 24px auto; }
}
.enroll-header {
  text-align: center;
  margin-bottom: 16px;
}
.enroll-consent {
  margin: 6px auto 0;
  max-width: 520px;
}
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.field-row.center {
  justify-content: center;
  gap: 10px;
}
.enroll-card .btn.ghost {
  color: var(--primary-dark);
  border-color: rgba(12, 111, 125, 0.25);
  background: #f4f8fa;
}
.enroll-card .icon-btn {
  background: #f4f8fa;
}
.btn.small {
  padding: 6px 10px;
  font-size: 12px;
}
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.icon-btn svg {
  width: 16px;
  height: 16px;
}
.icon-btn.camera-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
}
.icon-btn.camera-btn svg {
  width: 28px;
  height: 28px;
}
.camera-row {
  gap: 4px;
}
.selected-employee {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-dark);
}
.center-text {
  text-align: center;
}
.enroll-card .face-frame {
  margin-top: 4px;
}
.face-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.face-actions + .face-actions {
  margin-top: 14px;
}
.circle-btn {
  width: 140px;
  height: 140px;
  border-radius: 999px;
  border: none;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(12, 111, 125, 0.18);
}
.start-btn { background: linear-gradient(135deg, #1aa1a6, #0c6f7d); }
.capture-btn { background: linear-gradient(135deg, #f08b5b, #c65b2b); }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(9, 18, 24, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal.hidden {
  display: none;
}
.modal-card {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow: auto;
}
.modal-card input {
  border: 1px solid rgba(12, 111, 125, 0.35);
}
.modal-item {
  background: #f4f8fa;
  border: 1px solid rgba(12, 111, 125, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  color: #0f2a31;
  font-weight: 600;
}
.modal-item:hover {
  background: #e7f4f6;
  border-color: rgba(12, 111, 125, 0.3);
}
.modal-empty {
  text-align: center;
  color: var(--muted);
  padding: 14px;
}
@media (max-width: 640px) {
  .topbar.kiosk-top {
    position: sticky;
    top: 0;
    z-index: 40;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar.kiosk-top .brand {
    width: 100%;
  }
  .topbar.kiosk-top .status {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .card.wide.enroll-card {
    margin: 0;
    border-radius: 0;
    min-height: calc(100vh - 56px);
    padding-bottom: 40px;
  }
  .enroll-stack {
    padding: 0 8px;
  }
  .enroll-header h1 {
    font-size: 24px;
  }
  .enroll-consent {
    font-size: 13px;
  }
  .camera-row {
    flex-direction: column;
    gap: 4px;
  }
  .selected-employee {
    text-align: center;
  }
  #selectedCameraName {
    text-align: center;
  }
  .face-actions { gap: 10px; }
  .selected-employee { font-size: 13px; }
  .circle-btn {
    width: 120px;
    height: 120px;
    font-size: 13px;
  }
}

@media (max-width: 640px) {
  .modal-card {
    max-width: 100%;
    width: 100%;
  }
  .modal-list {
    max-height: 220px;
  }
}

.th-menu { position: relative; }
.th-menu .btn.ghost {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
  height: 32px;
  line-height: 1;
}
.th-dropdown {
  position: absolute;
  right: 0;
  top: 46px;
  background: #ffffff;
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow);
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}
.dropdown-group {
  border-top: 1px solid rgba(12, 111, 125, 0.12);
  padding-top: 6px;
}
.dropdown-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 4px 6px 2px;
}
.dropdown-item {
  background: #f3f7f8;
  color: var(--primary-dark);
  border: 1px solid rgba(12, 111, 125, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 0;
}
.dropdown-item svg { width: 18px; height: 18px; }
.dropdown-item.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.dropdown-item.danger:hover { filter: brightness(0.95); }
.th-dropdown.hidden { display: none; }

#methodTabs:not(.hidden) {
  animation: floatIn 0.4s ease;
}

#pinSubmit {
  width: 100%;
  height: 64px;
  font-size: 18px;
  border-radius: 14px;
}

@keyframes floatIn {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.consent { font-size: 12px; color: var(--muted); margin-top: 12px; }
