html {
  scrollbar-gutter: stable;
  overflow-y: scroll;
}

:root {
  --primary: #8e0b2c;
  --primary-dark: #720924;
  --secondary: #155cc0;
  --canvas: #f3f4f6;
  --topbar: 4rem;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  background: var(--canvas);
  color: #1f2937;
  font-family: Inter, Roboto, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; }

::selection { background: rgba(142, 11, 44, 0.16); }

.is-hidden { display: none !important; }

body.menu-lock,
body.lightbox-lock { overflow: hidden; }

#lightbox,
.lightbox,
.fancybox-container,
.lg-outer,
.image-viewer-modal {
  z-index: 99999 !important;
}

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
}

#lightbox-stage {
  position: absolute;
  inset: 4.75rem 0.5rem 6.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

#lightbox-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: default;
}

#lightbox-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem 0.75rem;
}

#lightbox-counter {
  margin: 0;
  min-width: 4.5rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#lightbox-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#download-lightbox,
#close-lightbox,
#lightbox-prev,
#lightbox-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
}

#download-lightbox,
#close-lightbox {
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.15rem;
}

#download-lightbox:hover,
#close-lightbox:hover,
#lightbox-prev:hover,
#lightbox-next:hover {
  background: rgba(255, 255, 255, 0.28);
}

#lightbox-prev,
#lightbox-next {
  position: absolute;
  top: calc(50% - 1.1rem);
  z-index: 3;
  width: 2.75rem;
  height: 3rem;
  font-size: 1.35rem;
}

#lightbox-prev { left: 0.65rem; }
#lightbox-next { right: 0.65rem; }
#lightbox-prev[hidden],
#lightbox-next[hidden] { display: none !important; }

#lightbox-thumbs {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.75rem 0.75rem max(0.75rem, env(safe-area-inset-bottom));
}

.lightbox-thumb {
  flex: 0 0 auto;
  width: 4.25rem;
  height: 4.25rem;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 0.45rem;
  overflow: hidden;
  background: #111;
  cursor: pointer;
}

.lightbox-thumb.is-active { border-color: #fff; }

.lightbox-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.pending-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 48rem;
  margin: 0 auto;
}

.pending-card {
  background: #fff;
  border-radius: 0.8rem;
  padding: 1rem 1rem 0.9rem;
  box-shadow: 0 10px 24px -18px rgba(17, 24, 39, 0.45);
  border: 1px solid rgba(17, 24, 39, 0.06);
}

.pending-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.pending-employee {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
}

.pending-time {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: #6b7280;
}

.pending-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  padding: 0.2rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.pending-content {
  margin-top: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.925rem;
  line-height: 1.6;
  color: #1f2937;
}

.pending-content.line-clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.pending-remove-image {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.8;
}

.pending-remove-image:hover {
  background: #dc2626;
  opacity: 1;
}

.pending-images { margin-top: 0.9rem; }

.pending-no-images {
  margin: 0.9rem 0 0;
  font-size: 0.875rem;
  color: #9ca3af;
}

.pending-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pending-note,
.pending-state {
  max-width: 48rem;
  margin: 0 auto 1rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background:
    radial-gradient(circle at 12% 18%, rgba(142, 11, 44, 0.10), transparent 32%),
    radial-gradient(circle at 90% 84%, rgba(21, 92, 192, 0.12), transparent 36%),
    var(--canvas);
}

.login-card {
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  border-radius: 1.25rem;
  background: #fff;
  box-shadow:
    0 24px 60px -28px rgba(17, 24, 39, 0.55),
    0 10px 24px -16px rgba(142, 11, 44, 0.45);
}

.logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto;
  border-radius: 1rem;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 12px 24px -12px rgba(142, 11, 44, 0.9);
}

#login-form { display: flex; flex-direction: column; gap: 1rem; }

.label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
}

.field { position: relative; width: 100%; }

.field-icon {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: 0.92rem;
  pointer-events: none;
}

.input {
  width: 100%;
  height: 2.85rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.8rem;
  background: #f9fafb;
  padding: 0 0.95rem;
  font-size: 0.95rem;
  color: #111827;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input::placeholder { color: #9ca3af; }

.input:focus {
  background: #fff;
  border-color: var(--secondary);
  box-shadow: 0 0 0 4px rgba(21, 92, 192, 0.13);
}

.input-icon { padding-left: 2.7rem; }
.input-trailing { padding-right: 2.7rem; }

.ghost-btn {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 0.6rem;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
}

.ghost-btn:hover { color: var(--secondary); }

.form-error {
  border-radius: 0.75rem;
  background: #fef2f2;
  color: #b91c1c;
  padding: 0.65rem 0.8rem;
  font-size: 0.875rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  border-radius: 0.8rem;
  padding: 0.72rem 1rem;
  font-size: 0.925rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.btn:active { transform: scale(0.99); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 16px -12px rgba(142, 11, 44, 0.9);
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: #fff;
  color: var(--secondary);
  border-color: var(--secondary);
}

.btn-secondary:hover {
  background: var(--secondary);
  color: #fff;
}

#login-form button[type="submit"] { width: 100%; height: 2.9rem; margin-top: 0.15rem; }

#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1060;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  height: var(--topbar);
  padding: 0 0.85rem;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 24px -16px rgba(142, 11, 44, 0.95);
}

@media (min-width: 640px) {
  #topbar { padding: 0 1.25rem; }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border: 0;
  border-radius: 0.75rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }

#btnSettings {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0.25rem;
  color: #fff;
  text-decoration: none;
}

#userInfoWrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  max-width: 11rem;
  line-height: 1.15;
  text-align: right;
}

#topbarUserName,
#topbarUserEmail {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.15;
}

#topbarUserName {
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
}

#topbarUserEmail {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.75rem;
}

@media (min-width: 640px) {
  #userInfoWrapper { max-width: 14rem; }
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 0.5rem;
  background: transparent;
  color: #fff;
  padding: 0.3rem 0.55rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.logout-btn:hover { background: rgba(255, 255, 255, 0.12); }
.logout-label { display: none; }
@media (min-width: 768px) { .logout-label { display: inline; } }

.d-flex { display: flex; }

#shell {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
  padding-top: var(--topbar);
  overflow: visible;
}

#main-content,
.properties-board {
  overflow: visible;
}

.filter-sidebar { align-self: flex-start; }

@media (max-width: 767.98px) {
  .filter-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (min-width: 768px) {
  .filter-sidebar {
    position: -webkit-sticky;
    position: sticky;
    top: calc(var(--topbar, 4rem) + 73px);
    z-index: 20;
    align-self: flex-start;
  }
}

@media (min-width: 1024px) {
  .filter-sidebar {
    max-height: calc(100vh - var(--topbar, 4rem) - 40px);
    overflow-y: auto;
  }
}

#backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.45);
}

#backdrop.is-visible { display: block; z-index: 1040; }

#sidebar.sidebar-container {
  position: fixed;
  top: var(--topbar);
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: 16rem;
  height: calc(100vh - var(--topbar));
  height: calc(100dvh - var(--topbar));
  overflow-y: auto;
  box-sizing: border-box;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  transform: translateX(-100%);
  transition: transform 0.28s ease, width 0.28s ease;
}

#sidebar.sidebar-container.is-open,
#sidebar.sidebar-container.show {
  transform: translateX(0);
  z-index: 1050;
  box-shadow: 12px 0 32px rgba(15, 23, 42, 0.12);
}

#sidebar.sidebar-container.is-open .sidebar-nav,
#sidebar.sidebar-container.is-open .sidebar-foot,
#sidebar.sidebar-container.show .sidebar-nav,
#sidebar.sidebar-container.show .sidebar-foot {
  visibility: visible;
  opacity: 1;
}

#sidebar.sidebar-container .sidebar-nav,
#sidebar.sidebar-container .sidebar-foot {
  opacity: 0;
  visibility: hidden;
}

#sidebar.sidebar-container.is-ready .sidebar-nav,
#sidebar.sidebar-container.is-ready .sidebar-foot {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.2s ease;
}

@media (min-width: 768px) {
  #sidebar.sidebar-container {
    transform: none;
    box-shadow: none;
  }

  #main-content { margin-left: 16rem; }

  #backdrop { display: none !important; }

  #sidebar.sidebar-container.is-collapsed { width: 5.25rem; }

  #sidebar.sidebar-container.is-collapsed ~ #main-content { margin-left: 5.25rem; }

  #sidebar.is-collapsed .nav-label,
  #sidebar.is-collapsed .nav-section,
  #sidebar.is-collapsed .sidebar-foot { display: none; }

  #sidebar.is-collapsed .nav-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.nav-section {
  margin: 0.15rem 0.4rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9ca3af;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  margin-bottom: 0.25rem;
  border: 0;
  border-radius: 0.8rem;
  background: transparent;
  padding: 0.72rem 0.75rem;
  text-align: left;
  font-size: 0.925rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-icon {
  display: inline-flex;
  width: 1.25rem;
  justify-content: center;
  font-size: 1rem;
}

.nav-label { white-space: nowrap; }

.nav-link:hover {
  background: rgba(21, 92, 192, 0.07);
  color: var(--secondary);
}

.nav-link.is-active {
  background: rgba(142, 11, 44, 0.09);
  color: var(--primary);
  font-weight: 700;
}

.nav-link.is-active:hover {
  background: rgba(142, 11, 44, 0.13);
  color: var(--primary);
}

.sidebar-foot {
  border-top: 1px solid #f3f4f6;
  padding: 0.9rem 1rem 1rem;
  font-size: 0.75rem;
  color: #9ca3af;
}

#main-content { flex: 1; min-width: 0; padding: 1.5rem 1rem 2.75rem; transition: margin-left 0.28s ease, opacity 0.18s ease; }
@media (min-width: 640px) { #main-content { padding: 1.75rem 1.5rem 3rem; } }
@media (min-width: 768px) { #main-content { margin-left: 16rem; } }
@media (min-width: 1024px) { #main-content { padding: 2rem 2rem 3.25rem; } }

.main-inner { width: 100%; max-width: 72rem; margin: 0 auto; }

[data-page] { animation: fade-up 0.28s ease; }

@keyframes fade-up {
  from { transform: translateY(6px); }
  to { transform: none; }
}

.chip {
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #fff;
  color: #374151;
  padding: 0.38rem 0.8rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.chip:hover { border-color: var(--secondary); color: var(--secondary); }

.chip.is-on {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

table.data {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

table.data th {
  background: #f9fafb;
  padding: 0.85rem 1rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7280;
  white-space: nowrap;
}

table.data td {
  padding: 0.95rem 1rem;
  border-top: 1px solid #f3f4f6;
  color: #374151;
  vertical-align: middle;
}

table.data tbody tr:hover td { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-info { background: rgba(21, 92, 192, 0.1); color: var(--secondary); }
.badge-admin { background: rgba(21, 92, 192, 0.12); color: #155cc0; }
.badge-user { background: #e5e7eb; color: #4b5563; }
.badge-ok { background: #ecfdf5; color: #047857; }
.badge-warn { background: #fffbeb; color: #b45309; }

.empty-state { padding: 2.75rem 1.25rem; text-align: center; }

.nav-link:focus-visible,
.module-card:focus-visible,
.btn:focus-visible,
.chip:focus-visible,
.icon-btn:focus-visible,
.logout-btn:focus-visible,
.ghost-btn:focus-visible,
.crumb:focus-visible {
  outline: 2px solid var(--secondary);
  outline-offset: 2px;
}

h1:focus { outline: none; }

.comment-panel {
  border-top: 1px solid #f3f4f6;
  padding: 0.75rem 1rem 1rem;
}

.comment-title {
  margin-bottom: 0.65rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: #111827;
}

.comment-list { display: flex; flex-direction: column; gap: 0.75rem; }

.comment-row { display: flex; align-items: flex-start; gap: 0.5rem; }

.comment-avatar {
  display: flex;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.comment-bubble {
  border-radius: 1rem;
  background: #f3f4f6;
  padding: 0.5rem 0.75rem;
}

.comment-name { font-size: 0.875rem; font-weight: 700; color: #111827; }

.comment-body {
  font-size: 0.875rem;
  color: #1f2937;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-time {
  margin-top: 0.25rem;
  padding-left: 0.25rem;
  font-size: 0.75rem;
  color: #6b7280;
}

.comment-empty { font-size: 0.875rem; color: #6b7280; }

.comment-form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.comment-input {
  flex: 1;
  min-width: 0;
  min-height: 2.5rem;
  max-height: 6.5rem;
  resize: vertical;
  border: 0;
  border-radius: 0.75rem;
  background: #f3f4f6;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  color: #1f2937;
}

.comment-input:focus { outline: 2px solid rgba(21, 92, 192, 0.35); }

.comment-send {
  height: 2.5rem;
  padding: 0 0.85rem;
  white-space: nowrap;
}

.logo-img {
  display: block;
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto;
  border-radius: 1rem;
  box-shadow: 0 12px 24px -12px rgba(142, 11, 44, 0.9);
}

/* Đảm bảo nền mờ của Modal nằm trên Topbar */
.modal-backdrop {
  z-index: 10400 !important;
}

/* Đảm bảo toàn bộ khung Modal Form nổi lên trên cùng (phải cao hơn backdrop) */
.modal {
  z-index: 10500 !important;
}

/* Trường hợp nếu Form dùng dạng Offcanvas trượt từ cạnh viền vào */
.offcanvas-backdrop {
  z-index: 10400 !important;
}
.offcanvas {
  z-index: 10500 !important;
}

#property-modal,
#edit-modal,
#prepare-modal {
  z-index: 10500 !important;
}
