:root {
  --bg: #f3f7fb;
  --panel: #ffffff;
  --border: #dfeaf6;
  --text: #1f2a37;
  --muted: #5d728b;
  --primary: #2563eb;
  --primary-soft: #dfe9ff;
  --present: #1f9d61;
  --present-soft: #dcfce7;
  --absent: #d93a3a;
  --absent-soft: #ffe4e6;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(180deg, #eef6ff 0%, var(--bg) 100%);
  color: var(--text);
}

body {
  display: flex;
  justify-content: center;
  padding: 32px 16px;
}

button, input, select, a {
  font: inherit;
}

.app-shell {
  width: min(980px, 100%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 20px;
}

.compact-topbar {
  align-items: center;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 2.8rem);
}

.front-card,
.manager-card,
.summary-card,
.table-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.front-page-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.front-card {
  position: relative;
  overflow: hidden;
  padding: 28px;
  max-width: 520px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(241,247,255,0.98) 100%);
  border: 1px solid rgba(130, 167, 255, 0.35);
  box-shadow: 0 22px 42px rgba(39, 78, 165, 0.12), inset 0 1px 0 rgba(255,255,255,0.7);
}

.front-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 110px;
  background: linear-gradient(135deg, rgba(110, 199, 255, 0.22), rgba(152, 111, 255, 0.10));
  pointer-events: none;
  z-index: 0;
}

.field-label {
  position: relative;
  z-index: 1;
  display: block;
  margin: 18px 0 8px;
  color: #485d7a;
  font-weight: 800;
}

.select-input,
input {
  position: relative;
  z-index: 1;
  width: 100%;
  border: 1px solid rgba(115, 148, 255, 0.35);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(237,245,255,0.96));
  padding: 12px 14px;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  box-shadow: inset 0 1px 2px rgba(96, 120, 197, 0.08);
}

input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.75);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.button-row {
  display: flex;
  gap: 12px;
  margin-top: 22px;
  position: relative;
  z-index: 1;
}

.primary-btn,
.secondary-btn,
.remove-btn,
.small-btn {
  padding: 12px 18px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-btn {
  background: linear-gradient(135deg, #48c5ff 0%, #2d7ff9 100%);
  color: white;
  box-shadow: 0 12px 22px rgba(45, 127, 249, 0.22);
}

.secondary-btn {
  background: linear-gradient(135deg, #8ae08b 0%, #2fa86f 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 12px 22px rgba(47, 168, 111, 0.18);
}

.secondary-btn.alt {
  background: linear-gradient(135deg, #ffbf6d 0%, #ff8d3d 100%);
  box-shadow: 0 12px 22px rgba(255, 141, 61, 0.2);
}

.primary-btn:hover,
.secondary-btn:hover,
.remove-btn:hover,
.small-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, #48c5ff 0%, #2d7ff9 100%);
  color: white;
  flex: 1;
  box-shadow: 0 12px 22px rgba(45, 127, 249, 0.2);
}

.secondary-btn {
  background: linear-gradient(135deg, #8ae08b 0%, #2fa86f 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 12px 22px rgba(47, 168, 111, 0.18);
}

.secondary-btn.alt {
  background: linear-gradient(135deg, #ffbf6d 0%, #ff8d3d 100%);
  box-shadow: 0 12px 22px rgba(255, 141, 61, 0.2);
}

.manager-link {
  text-decoration: none;
}

.status-message {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.approval-badge,
.decline-badge {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 3;
  transform: translateX(-50%) scale(0.4) rotate(-12deg);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 18px 24px rgba(31, 157, 97, 0.25));
  transition: opacity 0.25s ease, transform 0.35s ease;
}

.approval-badge::before,
.decline-badge::before {
  content: "";
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.36);
  opacity: 0;
}

.approval-badge {
  background: radial-gradient(circle at 30% 30%, #d9fbe6 0%, #38c172 30%, #1f9d61 100%);
  box-shadow: 0 0 0 10px rgba(56, 193, 114, 0.15), 0 18px 32px rgba(31, 157, 97, 0.28);
}

.decline-badge {
  background: radial-gradient(circle at 30% 30%, #ffe0e4 0%, #ef6b6b 30%, #d93a3a 100%);
  box-shadow: 0 0 0 10px rgba(217, 58, 58, 0.12), 0 18px 32px rgba(217, 58, 58, 0.24);
}

.approval-badge.show,
.decline-badge.show {
  opacity: 1;
  transform: translateX(-50%) scale(1) rotate(0deg);
  animation: statusPulse 0.85s ease-out;
}

.approval-badge.show::before,
.decline-badge.show::before {
  opacity: 1;
  animation: badgeRing 0.85s ease-out;
}

.approval-check,
.decline-mark {
  font-size: 3rem;
  line-height: 1;
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

@keyframes statusPulse {
  0% {
    transform: translateX(-50%) scale(0.4) rotate(-18deg);
    opacity: 0;
  }
  22% {
    opacity: 1;
  }
  50% {
    transform: translateX(-50%) scale(1.22) rotate(0deg);
  }
  100% {
    transform: translateX(-50%) scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes badgeRing {
  0% {
    transform: scale(0.7);
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  100% {
    transform: scale(1.3);
    opacity: 0;
  }
}

.manager-page {
  display: grid;
  gap: 22px;
}

.manager-section-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 14px;
  margin: 10px 0 18px;
}

.manager-section-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 110px;
  padding: 16px 12px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  color: white;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 12px 22px rgba(15, 23, 42, 0.14);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  text-transform: none;
}

.manager-section-btn::before {
  content: "";
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.manager-section-btn[data-manager-section="summary"] {
  background: linear-gradient(135deg, #5ec8ff 0%, #2d7ff9 100%);
}

.manager-section-btn[data-manager-section="addEmployee"] {
  background: linear-gradient(135deg, #8de27d 0%, #34b76f 100%);
}

.manager-section-btn[data-manager-section="updatePin"] {
  background: linear-gradient(135deg, #ffbe6b 0%, #ff8a3d 100%);
}

.manager-section-btn[data-manager-section="history"] {
  background: linear-gradient(135deg, #c29bff 0%, #7c5cff 100%);
}

.manager-section-btn[data-manager-section="roster"] {
  background: linear-gradient(135deg, #ff8ab4 0%, #f24f7a 100%);
}

.manager-section-btn:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 14px 26px rgba(15, 23, 42, 0.18);
  filter: saturate(1.08);
}

.manager-section-btn.active {
  outline: 3px solid rgba(255, 255, 255, 0.9);
  outline-offset: 2px;
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 16px 28px rgba(15, 23, 42, 0.2);
}

.manager-section[hidden] {
  display: none !important;
}

.summary-card {
  padding: 18px 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 16px;
}

.summary-item {
  border-radius: 14px;
  padding: 16px;
  background: #f7faff;
  border: 1px solid var(--border);
}

.summary-item strong {
  display: block;
  font-size: 2rem;
  margin-top: 8px;
}

.manager-card {
  padding: 20px;
}

.manager-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.log-control-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.range-controls,
.log-actions,
.custom-range-fields {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.custom-range-fields {
  border: 1px solid var(--border);
  background: #f9fbff;
  border-radius: 10px;
  padding: 8px 10px;
}

.custom-range-fields label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.custom-range-fields input {
  width: 130px;
}

.range-btn {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
}

.range-btn.active {
  background: var(--primary-soft);
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--primary);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.table-card {
  padding: 18px;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.employee-pin-update-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 20px 12px;
}

.badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge.present {
  background: var(--present-soft);
  color: var(--present);
}

.badge.absent {
  background: var(--absent-soft);
  color: var(--absent);
}

.inline-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--muted);
}

.auth-card {
  max-width: 420px;
  margin: 40px auto;
  background: linear-gradient(135deg, #ffffff 0%, #f4f8ff 100%);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 18px;
  box-shadow: 0 18px 38px rgba(37, 99, 235, 0.14), var(--shadow);
  padding: 24px;
  animation: cardEntrance 0.45s ease-out;
}

@keyframes cardEntrance {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-card h1 {
  margin-top: 0;
}

.auth-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.auth-actions .primary-btn,
.auth-actions .secondary-btn {
  flex: 1;
}

.auth-error {
  min-height: 22px;
  margin: 10px 0 14px;
  color: var(--absent);
  font-weight: 700;
}

@media (max-width: 700px) {
  body {
    padding: 20px 12px 28px;
  }

  .app-shell {
    width: min(100%, 460px);
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .manager-form,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .button-row,
  .auth-actions,
  .form-actions {
    flex-direction: column;
  }

  .primary-btn,
  .secondary-btn,
  .manager-link,
  .auth-actions .primary-btn,
  .auth-actions .secondary-btn {
    width: 100%;
    flex: 1 1 auto;
  }

  .front-card,
  .auth-card,
  .manager-card,
  .summary-card,
  .table-card {
    padding: 18px 14px;
    border-radius: 14px;
  }

  .table-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .history-header {
    align-items: flex-start;
  }

  .log-control-bar {
    justify-content: flex-start;
  }

  .field-label.inline-label {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .field-label.inline-label input {
    width: 100%;
  }

  th,
  td {
    padding: 10px 8px;
    font-size: 0.9rem;
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: 1.8rem;
  }

  .eyebrow {
    letter-spacing: 0.06em;
  }

  .topbar {
    gap: 10px;
  }

  .front-card,
  .auth-card,
  .manager-card,
  .summary-card,
  .table-card {
    padding: 16px 12px;
  }

  .status-message,
  .auth-error {
    font-size: 0.9rem;
  }

  .summary-item strong {
    font-size: 1.6rem;
  }
}
