:root {
  --color-orange-500: #f97316;
  --color-orange-600: #ea580c;
  --color-orange-700: #c2410c;
  --color-gold-400: #fbbf24;
  --color-cream: #fff8ed;
  --color-ink: #2f281e;
  --color-muted: #8c7c62;

  --bs-primary: var(--color-orange-500);
  --bs-primary-rgb: 249, 115, 22;
  --bs-link-color: var(--color-orange-500);
  --bs-link-hover-color: var(--color-orange-600);
  --bs-focus-ring-color: rgba(249, 115, 22, 0.33);
  --bs-body-bg: var(--color-cream);
  --bs-body-color: var(--color-ink);
  --bs-border-color: rgba(249, 115, 22, 0.14);
  --bs-border-radius: 0.9rem;
  --bs-border-radius-lg: 1.1rem;
  --bs-success: var(--color-orange-500);
  --bs-success-rgb: 249, 115, 22;
  --bs-danger: var(--color-orange-700);
  --bs-danger-rgb: 194, 65, 12;
  --bs-warning: var(--color-gold-400);
  --bs-warning-rgb: 251, 191, 36;
  --site-footer-height: 2.25rem;
}

[x-cloak] {
  display: none !important;
}

body {
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  padding-bottom: 4rem;
  font-feature-settings: "liga" 1, "kern" 1;
}

.message-toast-modal .modal-dialog {
  max-width: 420px;
}

.message-toast-modal__content {
  border: none;
  border-radius: 1.5rem;
  background: var(--color-cream);
  box-shadow: 0 24px 60px -32px rgba(15, 10, 5, 0.55);
  position: relative;
}

.message-toast-modal .modal-body {
  padding: 2.25rem 2rem 2rem;
}

.message-toast__wave {
  display: inline-block;
  margin-right: 0.4rem;
  animation: wave-hand 1.2s ease-in-out infinite;
  transform-origin: 70% 70%;
}

.message-toast__check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-orange-600), var(--color-orange-500));
  color: #fff;
  font-size: 0.9rem;
  margin-right: 0.45rem;
  box-shadow: 0 6px 14px -8px rgba(0, 0, 0, 0.4);
}

@keyframes wave-hand {
  0% { transform: rotate(0deg); }
  15% { transform: rotate(14deg); }
  30% { transform: rotate(-8deg); }
  45% { transform: rotate(14deg); }
  60% { transform: rotate(-4deg); }
  75% { transform: rotate(10deg); }
  100% { transform: rotate(0deg); }
}

a {
  color: var(--bs-link-color);
}

a:hover,
a:focus {
  color: var(--bs-link-hover-color);
}

/* Sidebar */
:root {
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 84px;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  height: 100vh;
  max-height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: 1.4rem 1.1rem calc(1.1rem + var(--site-footer-height));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #ffffff;
  border-right: 1px solid rgba(47, 40, 30, 0.08);
  box-shadow: 12px 0 40px -34px rgba(47, 40, 30, 0.35);
  transition: width 0.25s ease, padding 0.25s ease, box-shadow 0.25s ease;
  z-index: 1020;
}

body.sidebar-collapsed .sidebar,
.sidebar.sidebar--collapsed {
  width: var(--sidebar-collapsed-width);
  flex: 0 0 var(--sidebar-collapsed-width);
  padding: 1rem 0.5rem calc(1rem + var(--site-footer-height));
  box-shadow: 6px 0 24px -14px rgba(15, 10, 5, 0.55);
}

body.sidebar-collapsed .sidebar__brand-text,
.sidebar.sidebar--collapsed .sidebar__brand-text,
body.sidebar-collapsed .sidebar__section-label,
.sidebar.sidebar--collapsed .sidebar__section-label,
body.sidebar-collapsed .sidebar__label,
.sidebar.sidebar--collapsed .sidebar__label,
body.sidebar-collapsed .sidebar__profile-text,
.sidebar.sidebar--collapsed .sidebar__profile-text,
body.sidebar-collapsed .sidebar__logout-text,
.sidebar.sidebar--collapsed .sidebar__logout-text {
  display: none;
}

body.sidebar-collapsed .sidebar__link,
.sidebar.sidebar--collapsed .sidebar__link,
body.sidebar-collapsed .sidebar__link--child,
.sidebar.sidebar--collapsed .sidebar__link--child {
  justify-content: center;
  padding: 0.5rem 0.4rem;
  border: none;
}

body.sidebar-collapsed .sidebar__icon,
.sidebar.sidebar--collapsed .sidebar__icon {
  margin: 0 auto;
  background: rgba(249, 115, 22, 0.12);
}

body.sidebar-collapsed .sidebar__children,
.sidebar.sidebar--collapsed .sidebar__children {
  margin-left: 0;
}

body.sidebar-collapsed .sidebar__profile-card,
.sidebar.sidebar--collapsed .sidebar__profile-card {
  justify-content: center;
  background: transparent;
  border: none;
}

body.sidebar-collapsed .sidebar__brand-icon,
.sidebar.sidebar--collapsed .sidebar__brand-icon {
  display: none;
}

body.sidebar-collapsed .sidebar__logout,
.sidebar.sidebar--collapsed .sidebar__logout {
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 999px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 10, 5, 0.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1030;
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 0.8rem;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 0.85rem;
  border-radius: 1rem;
  background: linear-gradient(140deg, var(--color-orange-600) 0%, var(--color-orange-500) 100%);
  color: #ffffff;
  box-shadow: 0 20px 40px -28px rgba(234, 88, 12, 0.85);
}

.sidebar__brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
}

.sidebar__brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.sidebar__brand-tagline {
  font-size: 0.7rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  opacity: 0.8;
}

.sidebar__brand-text {
  flex: 1;
  min-width: 0;
}

.sidebar__collapse-toggle {
  margin-left: auto;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  padding: 0.35rem 0.55rem;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  transition: background 0.2s ease, transform 0.2s ease;
}

.sidebar__collapse-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.sidebar__menu {
  margin-top: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: 1rem;
}

.sidebar__section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(47, 40, 30, 0.5);
}

.sidebar__nav {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-right: 0.2rem;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.68rem 0.85rem;
  border-radius: 0.85rem;
  color: var(--color-ink);
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.sidebar__link:hover {
  border-color: rgba(249, 115, 22, 0.2);
  background: rgba(249, 115, 22, 0.08);
  transform: translateX(4px);
  color: var(--color-orange-700);
}

.sidebar__link--active {
  background: rgba(249, 115, 22, 0.12);
  border-color: rgba(249, 115, 22, 0.28);
  box-shadow: 0 20px 32px -28px rgba(249, 115, 22, 0.6);
  color: var(--color-orange-700);
}

.sidebar__icon {
  width: 30px;
  height: 30px;
  border-radius: 0.9rem;
  background: rgba(249, 115, 22, 0.12);
  color: var(--color-orange-600);
  display: grid;
  place-items: center;
  font-size: 1rem;
}

.sidebar__link--active .sidebar__icon {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.95), rgba(251, 191, 36, 0.9));
  color: #ffffff;
}

.sidebar__label {
  flex: 1;
  font-size: 0.9rem;
}

.sidebar__link--child {
  margin-left: 0.8rem;
  padding-left: 0.65rem;
  font-size: 0.85rem;
  color: rgba(47, 40, 30, 0.82);
}

.sidebar__link--child .sidebar__icon {
  width: 26px;
  height: 26px;
  border-radius: 0.8rem;
  font-size: 0.9rem;
  background: rgba(249, 115, 22, 0.08);
}

.sidebar__profile {
  margin-top: auto;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(47, 40, 30, 0.08);
}

.sidebar__profile-card {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.8rem;
  border-radius: 0.95rem;
  background: rgba(249, 115, 22, 0.08);
  border: 1px solid rgba(249, 115, 22, 0.16);
}

.sidebar__avatar {
  width: 38px;
  height: 38px;
  border-radius: 1.05rem;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.92rem;
  color: #ffffff;
  background: linear-gradient(140deg, var(--color-orange-600), var(--color-orange-500));
  box-shadow: 0 12px 20px -14px rgba(234, 88, 12, 0.8);
}

.sidebar__profile-name {
  font-size: 0.88rem;
  font-weight: 600;
}

.sidebar__profile-role {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(47, 40, 30, 0.55);
}

.sidebar__profile-email {
  font-size: 0.72rem;
  color: rgba(47, 40, 30, 0.65);
}

.sidebar__logout {
  margin-top: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.7rem 0.85rem;
  border-radius: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--color-orange-600), var(--color-orange-700));
  color: #ffffff;
  box-shadow: 0 16px 26px -18px rgba(194, 65, 12, 0.8);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sidebar__logout:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 32px -18px rgba(194, 65, 12, 0.88);
  color: #ffffff;
}

body.sidebar-open {
  overflow: hidden;
}

body.sidebar-open .sidebar-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-105%);
    height: 100vh;
    max-height: none;
    border-radius: 0;
    margin: 0;
    padding: 1.4rem 1.4rem calc(1.4rem + var(--site-footer-height));
    overflow-y: auto;
    width: min(82vw, 300px);
    max-width: 320px;
    transition: transform 0.3s ease;
    box-shadow: 22px 0 48px -28px rgba(47, 40, 30, 0.55);
    z-index: 1040;
  }

  .sidebar__menu {
    margin-top: 1rem;
  }

  .sidebar__profile {
    margin-top: 1.25rem;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
}

.btn-primary {
  --bs-btn-bg: var(--color-orange-500);
  --bs-btn-border-color: var(--color-orange-500);
  --bs-btn-hover-bg: var(--color-orange-600);
  --bs-btn-hover-border-color: var(--color-orange-600);
  --bs-btn-focus-shadow-rgb: 249, 115, 22;
  --bs-btn-active-bg: var(--color-orange-700);
  --bs-btn-active-border-color: var(--color-orange-700);
}

.btn-outline-primary {
  --bs-btn-color: var(--color-orange-500);
  --bs-btn-border-color: rgba(249, 115, 22, 0.55);
  --bs-btn-hover-bg: var(--color-orange-500);
  --bs-btn-hover-border-color: var(--color-orange-500);
  --bs-btn-active-bg: var(--color-orange-600);
  --bs-btn-active-border-color: var(--color-orange-600);
}

.form-control,
.form-select {
  border-radius: 0.75rem;
  border-color: rgba(249, 115, 22, 0.2);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(249, 115, 22, 0.65);
  box-shadow: 0 0 0 0.25rem rgba(249, 115, 22, 0.18);
}

/* Range filter */
.range-filter {
  position: relative;
  min-width: 260px;
}

.range-filter__display {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid rgba(249, 115, 22, 0.35);
  border-radius: 0.85rem;
  background: #ffffff;
  padding: 0.35rem 0.85rem;
  font-size: 0.92rem;
  color: var(--color-ink);
  box-shadow: 0 6px 20px -12px rgba(47, 40, 30, 0.35);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.range-filter__display:hover,
.range-filter.range-filter--open .range-filter__display {
  border-color: rgba(249, 115, 22, 0.65);
  box-shadow: 0 10px 28px -16px rgba(47, 40, 30, 0.45);
}

.range-filter__display-icon {
  color: var(--color-orange-500);
}

.range-filter__display-caret {
  margin-left: auto;
  color: rgba(47, 40, 30, 0.55);
}

.range-filter__panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: auto;
  width: auto;
  min-width: min(680px, calc(100vw - 2rem));
  max-width: min(960px, calc(100vw - 2rem));
  background: #ffffff;
  border-radius: 1rem;
  border: 1px solid rgba(47, 40, 30, 0.12);
  box-shadow: 0 24px 60px -28px rgba(15, 10, 5, 0.35);
  padding: 1rem;
  display: none;
  gap: 1.5rem;
  align-items: stretch;
  z-index: 1050;
}

.range-filter.range-filter--open .range-filter__panel {
  display: flex;
}

.range-filter.range-filter--align-right .range-filter__panel {
  left: auto;
  right: 0;
}

.range-filter__quick {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 190px;
  flex: 0 0 190px;
}

.range-filter__quick-btn {
  border: none;
  background: transparent;
  text-align: left;
  padding: 0.35rem 0.9rem;
  border-radius: 0.65rem;
  font-size: 0.9rem;
  color: rgba(47, 40, 30, 0.75);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.range-filter__quick-btn:hover,
.range-filter__quick-btn.is-active {
  background: rgba(249, 115, 22, 0.12);
  color: var(--color-orange-600);
  font-weight: 600;
}

.range-filter__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 360px;
}

.range-filter__calendar {
  flex: 1;
  min-width: 420px;
}

.range-filter__calendar .litepicker {
  width: auto;
  border: none;
  box-shadow: none;
  background: transparent;
}

.range-filter__calendar .litepicker .container__months {
  display: flex;
  flex-wrap: nowrap;
  gap: 1.4rem;
}

.range-filter__calendar .litepicker .month-item {
  flex: 1 1 0;
  min-width: 240px;
}
.range-filter__calendar .litepicker .container__days > a,
.range-filter__calendar .litepicker .container__days > div {
  flex: 0 0 calc(100% / 7);
  max-width: calc(100% / 7);
  width: calc(100% / 7);
  box-sizing: border-box;
}

.range-filter__actions {
  display: flex;
  justify-content: flex-end;
}

.range-filter__actions .btn {
  min-width: 80px;
}

@media (max-width: 576px) {
  .range-filter__panel {
    left: 0;
    right: 0;
    min-width: 0;
    flex-direction: column;
    gap: 0.75rem;
  }

  .range-filter__main {
    min-width: 0;
  }

  .range-filter__calendar {
    min-width: 0;
  }

  .range-filter__calendar .litepicker .container__months {
    flex-wrap: wrap;
    gap: 1rem;
  }
  .range-filter__calendar .litepicker .container__days > a,
  .range-filter__calendar .litepicker .container__days > div {
    flex-basis: calc(100% / 7);
  }
}

.sidebar__group {
  border-radius: 0.95rem;
  border: 1px solid transparent;
  padding: 0.1rem;
}

.sidebar__group--open {
  border-color: rgba(249, 115, 22, 0.18);
  background: rgba(249, 115, 22, 0.04);
}

.sidebar__link--toggle {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding-right: 0.2rem;
}

.sidebar__link--toggle:focus-visible {
  outline: 2px solid rgba(249, 115, 22, 0.6);
  outline-offset: 3px;
}

.sidebar__caret {
  color: rgba(47, 40, 30, 0.5);
  transition: transform 0.2s ease;
}

.sidebar__group--open .sidebar__caret {
  transform: rotate(180deg);
}

.sidebar__children {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.2rem 0 0 0.5rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.sidebar__group--open .sidebar__children {
  max-height: 600px;
}

.card {
  border-radius: 1.05rem;
  border: 1px solid rgba(249, 115, 22, 0.08);
}

.stat-card {
  background: #ffffff;
  border: 1px solid rgba(249, 115, 22, 0.14);
  border-radius: 0.95rem;
  padding: 1rem 1.2rem;
  box-shadow: 0 18px 40px -34px rgba(47, 40, 30, 0.38);
  transition: transform 0.2s ease, box-shadow 0.25s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 50px -36px rgba(47, 40, 30, 0.5);
}

.stat-card__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: rgba(47, 40, 30, 0.65);
}

.stat-card__value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-ink);
}

.stat-card__value--accent {
  color: var(--color-orange-500);
}

.stat-card__value--alert {
  color: var(--color-orange-700);
}

.stat-card__meta {
  font-size: 0.75rem;
  color: rgba(47, 40, 30, 0.6);
}

.stat-card--period {
  background: linear-gradient(130deg, rgba(251, 191, 36, 0.35), rgba(249, 115, 22, 0.12));
}

.stat-card--present {
  background: linear-gradient(130deg, rgba(249, 115, 22, 0.2), rgba(249, 115, 22, 0.08));
}

.stat-card--absent {
  background: linear-gradient(130deg, rgba(194, 65, 12, 0.28), rgba(249, 115, 22, 0.1));
}

.stat-card--users {
  background: linear-gradient(130deg, rgba(255, 248, 237, 0.96), rgba(251, 191, 36, 0.24));
}

.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #0d0d0d;
  border-top: 1px solid rgba(249, 115, 22, 0.28);
  z-index: 1030;
  padding: 0.35rem 0.9rem;
  color: #ffffff;
}

.table thead th {
  color: rgba(47, 40, 30, 0.75);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.96);
}

.text-success {
  color: var(--color-orange-500) !important;
}

.text-danger {
  color: var(--color-orange-700) !important;
}

/* Photo action buttons inside Timekeeping records */
.photo-action {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  border: 1px dashed rgba(47, 40, 30, 0.2);
  border-radius: 0.6rem;
  padding: 0.3rem 0.45rem;
  background-color: #fff;
  min-width: 110px;
  gap: 0.35rem;
}

.dropdown-toggle-icon::after {
  margin-left: 0.25rem;
}

.dropdown-menu-photo {
  min-width: 150px;
  padding: 0.2rem 0;
}

.btn-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.records-page {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.records-table-scroll {
  width: 100%;
  max-width: 100%;
  min-height: 320px;
  max-height: calc(100vh - 240px);
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
  background: #fffaf3;
  scroll-behavior: smooth;
}

.records-table-scroll table {
  border-collapse: separate;
  border-spacing: 0;
}

.records-table-scroll thead tr {
  position: sticky;
  top: 0;
  z-index: 8;
}

.records-table-scroll thead th,
.records-table-scroll thead th::before {
  position: sticky;
  top: 0;
  z-index: 9;
  background: #ffffff;
  box-shadow: 0 4px 8px -6px rgba(0, 0, 0, 0.35);
}

.timekeeping-records-table th,
.timekeeping-records-table td {
  font-size: 0.82rem;
  vertical-align: middle;
  white-space: nowrap;
  padding: 0.35rem;
}

.timekeeping-records-table .photo-action {
  min-width: 110px;
}

.timekeeping-records-table {
  table-layout: auto;
  width: 100%;
  min-width: 1200px;
}

.timekeeping-records-table .btn {
  font-size: 0.72rem;
  padding: 0.25rem 0.5rem;
}

.device-cell .btn {
  width: 32px;
  height: 32px;
  padding: 0;
}

.records-pagination .btn.disabled,
.records-pagination .btn:disabled {
  pointer-events: none;
  opacity: 0.4;
}

.entries-form .form-select {
  min-width: 90px;
}

html,
body,
main {
  max-width: 100%;
  overflow-x: hidden;
}

.timekeeping-records-table th:nth-child(1),
.timekeeping-records-table td:nth-child(1) {
  min-width: 150px;
}

.timekeeping-records-table th:nth-child(2),
.timekeeping-records-table td:nth-child(2) {
  min-width: 210px;
}

.timekeeping-records-table th:nth-child(3),
.timekeeping-records-table td:nth-child(3) {
  min-width: 110px;
}
