/* ─── Reset & Base ──────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2563eb;
  --primary-h: #1d4ed8;
  --success: #16a34a;
  --success-h: #15803d;
  --danger: #dc2626;
  --bg: #f0f4fa;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --radius: 12px;
  --shadow: 0 8px 26px rgba(15, 23, 42, .08);
}

body {
  font-family: 'Inter', Arial, sans-serif;
  background: radial-gradient(circle at 10% 0%, #e8f0ff 0%, var(--bg) 35%, #f8fbff 100%);
  color: var(--text);
  min-height: 100vh;
}

/* ─── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
  background: linear-gradient(135deg, #0b1329 0%, #1e293b 100%);
  box-shadow: 0 10px 25px rgba(0, 0, 0, .2);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.topbar-inner {
  max-width: min(98vw, 1800px);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
}

.topbar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 52px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  width: 100%;
}

.topbar-bottom {
  display: flex;
  align-items: center;
  min-height: 48px;
  width: 100%;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE 10+ */
}

.topbar-bottom::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Edge */
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.5px;
  white-space: nowrap;
  user-select: none;
}

.logo-icon {
  font-size: 22px;
  display: inline-block;
  animation: logo-float 3s ease-in-out infinite;
}

@keyframes logo-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

#currentUserLabel {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.08);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

#currentUserLabel:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-logout {
  background: rgba(239, 68, 68, 0.12) !important;
  color: #f87171 !important;
  border: 1px solid rgba(239, 68, 68, 0.25) !important;
  padding: 6px 12px !important;
  font-size: 13px !important;
  border-radius: 8px !important;
  font-weight: 500 !important;
  transition: all 0.2s ease !important;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.25) !important;
  color: #fff !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15) !important;
}

/* ─── Tabs ──────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 6px;
  padding: 6px 0;
  white-space: nowrap;
}

.tab-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .2s, color .2s, transform 0.1s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* ─── Tab content ───────────────────────────────────────────────────────── */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ─── Container ─────────────────────────────────────────────────────────── */
.container {
  max-width: min(98vw, 1800px);
  margin: 0 auto;
  padding: 14px 16px;
}

/* ─── Card ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

.card h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s, transform .1s, box-shadow .18s;
  white-space: nowrap;
}

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

.btn:hover {
  box-shadow: 0 6px 16px rgba(15, 23, 42, .14);
}

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

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

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

.btn-success:hover {
  background: var(--success-h);
}

.btn-warning {
  background: #f59e0b;
  color: #fff;
}

.btn-warning:hover {
  background: #d97706;
}

.btn-secondary {
  background: #475569;
  color: #fff;
}

.btn-secondary:hover {
  background: #334155;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 5px 12px;
  font-size: 13px;
}

.btn-danger:hover {
  background: #fef2f2;
}

/* ─── Filter bar ────────────────────────────────────────────────────────── */
.filter-bar {
  padding: 16px 20px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 200px;
}

.filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.filter-actions {
  flex-direction: row;
  flex: 0;
  align-items: flex-end;
  gap: 8px;
  min-width: auto;
}

.density-mode-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.btn-density {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 7px 10px;
  font-size: 13px;
}

.btn-density:hover {
  background: #eef2ff;
  color: #1e3a8a;
  box-shadow: none;
}

.btn-density.active {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
}

.count-label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
}

/* ─── Inputs ────────────────────────────────────────────────────────────── */
input[type="text"],
input[type="date"],
input[type="month"],
input[type="number"],
input[type="password"],
select {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color .18s, box-shadow .18s;
  width: 100%;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

/* ─── Autocomplete ──────────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
}

.search-wrap input {
  padding-right: 32px;
}

.search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  display: none;
  align-items: center;
  justify-content: center;
  transition: color .15s, transform .1s;
  z-index: 10;
}

.search-clear-btn:hover {
  color: var(--danger);
  transform: translateY(-50%) scale(1.15);
}

.search-clear-btn:active {
  transform: translateY(-50%) scale(0.95);
}

.autocomplete-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 280px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .16);
  z-index: 200;
  max-height: 340px;
  overflow-y: auto;
}

.autocomplete-list.open {
  display: block;
}

.autocomplete-item {
  padding: 11px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: #eff6ff;
}

.autocomplete-group-header {
  padding: 8px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .5px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  pointer-events: none;
  user-select: none;
}

/* Dept headers with a dept value are clickable */
.autocomplete-group-header[data-dept]:not([data-dept=""]) {
  pointer-events: auto;
  cursor: pointer;
}

.autocomplete-group-header[data-dept]:not([data-dept=""]):hover {
  background: #eff6ff;
  color: #1d4ed8;
}

.autocomplete-group-header:first-child {
  border-top: none;
}

.autocomplete-item .emp-badge {
  font-size: 11px;
  background: #dbeafe;
  color: var(--primary);
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 600;
}

/* ─── Layout: list + map ────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(320px, 1fr);
  gap: 12px;
}

.scroll-card {
  overflow: hidden;
}

.map-card {
  overflow: hidden;
}

#map {
  width: 100%;
  height: 560px;
  border-radius: 8px;
}

/* ─── Check-in list ─────────────────────────────────────────────────────── */
.list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 10px;
  max-height: 560px;
  overflow-y: auto;
  padding-right: 4px;
}

.list.density-normal {
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
}

.list.density-dense {
  grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
}

.list.density-dense .item img {
  height: 95px;
}

.list.density-ultra {
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
}

.list.density-ultra .item img {
  height: 80px;
}

.list::-webkit-scrollbar {
  width: 5px;
}

.list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.item {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s, transform .15s;
  background: #fff;
}

.item:hover {
  border-color: var(--primary);
  box-shadow: 0 10px 20px rgba(37, 99, 235, .13);
  transform: translateY(-1px);
}

.item-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.item-info {
  padding: 8px 10px 10px;
}

.item-meta {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trip-tag {
  display: inline-block;
  padding: 2px 6px;
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fdba74;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.item-zone {
  font-size: 11px;
  color: var(--muted);
}

.item img {
  width: 100%;
  height: 110px;
  object-fit: contain;
  object-position: center;
  background: #f1f5f9;
  display: block;
  border-bottom: 1px solid var(--border);
}

@media (min-width: 1440px) {

  .list,
  .list.density-normal {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    max-height: 640px;
  }

  .list.density-dense {
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  }

  .list.density-ultra {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }

  #map {
    height: 640px;
  }
}

@media (min-width: 1920px) {
  .layout {
    grid-template-columns: minmax(0, 2.1fr) minmax(360px, 0.9fr);
  }

  .list,
  .list.density-normal {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .list.density-dense {
    grid-template-columns: repeat(auto-fill, minmax(102px, 1fr));
  }

  .list.density-ultra {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  }

  .item img {
    height: 100px;
  }
}

/* ─── Employee tab ──────────────────────────────────────────────────────── */
.emp-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.emp-message {
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

.emp-message.ok {
  color: var(--success);
}

.emp-message.err {
  color: var(--danger);
}

.emp-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.emp-list-header h2 {
  margin-bottom: 0;
}

.emp-search-input {
  width: 220px;
}

.emp-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 460px;
  overflow-y: auto;
  padding-right: 4px;
}

.emp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  transition: border-color .15s;
  gap: 12px;
}

.emp-item:hover {
  border-color: #94a3b8;
}

.emp-item-info {
  flex: 1;
}

.emp-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.face-group-item {
  align-items: flex-start;
}

.face-group-toggle {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  margin-bottom: 2px;
}

.face-group-toggle-icon {
  display: inline-block;
  transition: transform .18s;
  color: var(--muted);
}

.face-group-toggle.collapsed .face-group-toggle-icon {
  transform: rotate(-90deg);
}

.face-group-toggle-name {
  font-size: 15px;
  font-weight: 700;
}

.face-thumb-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.face-thumb-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  background: #f8fafc;
}

.face-thumb-item img {
  width: 100%;
  height: 86px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  display: block;
}

.face-thumb-empty {
  width: 100%;
  height: 86px;
  border-radius: 8px;
  border: 1px dashed #cbd5e1;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.face-thumb-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  word-break: break-word;
}

.face-thumb-grid.collapsed {
  display: none;
}

.emp-item-name {
  font-weight: 600;
  font-size: 15px;
}

.emp-item-dept {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.emp-no-data {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 24px;
}

#authSection .card {
  border: 1px solid #dbeafe;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

#authSection .card h2 {
  margin-bottom: 18px;
}

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar-inner {
    padding: 0 12px;
  }

  .topbar-top {
    height: 48px;
  }

  .topbar-bottom {
    min-height: 44px;
  }

  .tabs {
    gap: 4px;
  }

  .tab-btn {
    padding: 6px 12px;
    font-size: 13px;
  }
}

@media (max-width: 560px) {
  .filter-row {
    flex-direction: column;
  }

  .filter-group {
    min-width: 100%;
  }

  .filter-actions {
    flex-direction: row;
  }

  .density-mode-group {
    min-width: 100%;
    justify-content: space-between;
  }

  .btn-density {
    flex: 1;
    justify-content: center;
  }
}

/* ─── Help / Hướng dẫn ──────────────────────────────────────────────────── */
.help-section {
  margin-bottom: 14px;
}

.help-section > h2 {
  font-size: 20px;
  margin-bottom: 6px;
}

.help-intro {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 0;
}

.help-header {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  transition: background .15s;
  border-radius: 6px;
}

.help-header:hover {
  background: #f1f5f9;
}

.help-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.help-toggle-icon {
  display: inline-block;
  font-size: 14px;
  color: var(--primary);
  transition: transform .2s;
  width: 16px;
  flex-shrink: 0;
}

.help-header.open .help-toggle-icon {
  transform: rotate(90deg);
}

.help-body {
  display: none;
  padding: 12px 0 4px 26px;
}

.help-body.open {
  display: block;
}

.help-steps {
  padding-left: 20px;
  color: #334155;
  font-size: 14px;
  line-height: 1.7;
}

.help-steps li {
  margin-bottom: 6px;
}

.help-steps ul {
  padding-left: 18px;
  margin-top: 4px;
}

.help-steps ul li {
  margin-bottom: 3px;
}

.help-steps code {
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: #7c3aed;
}

.help-tip {
  margin-top: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: #1e40af;
}

.help-note {
  font-size: 13px;
  color: #b45309;
  font-weight: 600;
  margin-bottom: 8px;
}

.help-badge-admin {
  display: inline-block;
  font-size: 11px;
  background: #fef3c7;
  color: #92400e;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 600;
  vertical-align: middle;
  margin-left: 6px;
}

/* ─── Zones tab ─────────────────────────────────────────────────────────── */
.btn-sm {
  padding: 6px 13px;
  font-size: 13px;
  border-radius: 8px;
}

.zones-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 380px;
  gap: 14px;
  align-items: start;
}

@media (max-width: 1100px) {
  .zones-layout {
    grid-template-columns: 1fr;
  }
}

.zones-map-card {
  padding: 0;
  overflow: hidden;
}

.zones-map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, #f8fafc 0%, #eff6ff 100%);
  gap: 10px;
  flex-wrap: wrap;
}

.zones-toolbar-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
}

.zones-map-search {
  flex: 1;
  min-width: 200px;
  max-width: 450px;
  display: flex;
  gap: 4px;
}

#zoneSearchAddr {
  height: 34px;
  font-size: 13px;
  padding: 0 12px;
}

#btnSearchAddr {
  padding: 0 10px;
  height: 34px;
  flex-shrink: 0;
}

.zones-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#zonesMap {
  width: 100%;
  height: 540px;
}

.zones-map-hint {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

.zones-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Zone form */
.zone-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.zone-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.zone-poly-preview {
  font-size: 12px;
  color: var(--muted);
  background: #f8fafc;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-family: monospace;
  line-height: 1.5;
}

/* Zone list */
.zone-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 2px;
}

.zone-item {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.zone-item:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 12px rgba(37,99,235,.1);
}

.zone-item.inactive {
  opacity: .55;
  border-style: dashed;
}

.zone-item-info {
  flex: 1;
  min-width: 0;
}

.zone-item-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.zone-type-badge {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.zone-type-badge.circle {
  background: #dbeafe;
  color: #1d4ed8;
}

.zone-type-badge.polygon {
  background: #d1fae5;
  color: #065f46;
}

.zone-status-badge {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.zone-status-badge.active {
  background: #dcfce7;
  color: #15803d;
}

.zone-status-badge.inactive {
  background: #f1f5f9;
  color: #64748b;
}

.zone-item-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.6;
}

.zone-item-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}

.btn-zone-edit {
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #bfdbfe;
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: background .15s;
  white-space: nowrap;
}

.btn-zone-edit:hover {
  background: #dbeafe;
}

.btn-zone-toggle {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: background .15s;
  white-space: nowrap;
}

.btn-zone-toggle.deactivate {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}

.btn-zone-toggle:hover {
  filter: brightness(.95);
}

.btn-zone-del {
  background: transparent;
  color: var(--danger);
  border: 1px solid #fca5a5;
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: background .15s;
  white-space: nowrap;
}

.btn-zone-del:hover {
  background: #fef2f2;
}

.zone-no-data {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 24px;
}

/* Draw mode hint */
#zonesMap.draw-active {
  cursor: crosshair !important;
}

/* Hide routing instructions text box to keep map clean */
.leaflet-routing-container {
  display: none;
}

/* Zone tooltip trên bản đồ chính */
.zone-tooltip {
  background: rgba(15, 23, 42, 0.82);
  color: #f8fafc;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  padding: 5px 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  pointer-events: none;
}
.zone-tooltip::before {
  border-top-color: rgba(15, 23, 42, 0.82) !important;
}

/* ─── Admin Checkin Management ──────────────────────────────────────────────── */

/* Badges trên item checkin */
.badge-edited {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  background: #ccfbf1;
  color: #0f766e;
  border: 1px solid #99f6e4;
  white-space: nowrap;
}

.badge-admin-added {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #c4b5fd;
  white-space: nowrap;
}

/* Nút hành động admin trên item — Ẩn mặc định, chỉ hiện khi chế độ sửa bật */
.item-admin-actions {
  display: none;
  gap: 4px;
  padding: 4px 8px 6px;
  border-top: 1px solid var(--border);
  background: #fafafa;
  justify-content: flex-end;
}

/* Khi #list có class edit-mode → hiện nút */
.list.edit-mode .item-admin-actions {
  display: flex;
}

.btn-admin-edit {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}

.btn-admin-edit:hover {
  background: #dbeafe;
}

.btn-admin-delete {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #fca5a5;
  background: #fff1f2;
  color: #dc2626;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}

.btn-admin-delete:hover {
  background: #fee2e2;
}

/* N\u00fat b\u1eadt/t\u1eaft ch\u1ebf \u0111\u1ed9 s\u1eeda */
.btn-edit-mode-toggle {
  display: none; /* ch\u1ec9 admin m\u1edbi th\u1ea5y, hi\u1ec7n b\u1eb1ng JS */
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s, box-shadow .18s;
  white-space: nowrap;
  gap: 5px;
}

.btn-edit-mode-toggle:hover {
  background: #fef9c3;
  border-color: #fde047;
  color: #713f12;
}

.btn-edit-mode-toggle.active {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .15);
}

/* Modal overlay */
.checkin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Modal container */
.checkin-modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .22);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.checkin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}

.checkin-modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.checkin-modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}

.checkin-modal-close:hover {
  background: #f1f5f9;
  color: var(--danger);
}

.checkin-modal-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.checkin-modal-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.checkin-modal-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.checkin-modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkin-modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
}

/* Panel dữ liệu gốc */
.original-data-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #475569;
  line-height: 1.6;
  max-height: 180px;
  overflow-y: auto;
}

.original-data-panel .orig-row {
  display: flex;
  gap: 8px;
}

.original-data-panel .orig-key {
  font-weight: 700;
  color: #0f766e;
  min-width: 120px;
}

.original-data-panel .orig-val {
  color: #334155;
  word-break: break-all;
}

textarea.checkin-modal-textarea {
  resize: vertical;
  min-height: 60px;
}

.checkin-modal-msg {
  font-size: 13px;
  min-height: 18px;
  color: var(--danger);
}

.checkin-modal-msg.ok {
  color: var(--success);
}

/* ─── Face Add Suggestions Tab ──────────────────────────────────────────────── */
.face-suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.face-suggestion-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.face-suggestion-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.face-suggestion-img-wrap {
  width: 100%;
  height: 220px;
  background: #f1f5f9;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.face-suggestion-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.face-suggestion-no-img {
  color: var(--muted);
  font-size: 14px;
}

.face-suggestion-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 10px;
}

.face-suggestion-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px 0;
}

.face-suggestion-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

.face-suggestion-meta .meta-label {
  font-weight: 500;
}

.face-suggestion-meta .meta-value {
  color: var(--text);
  font-weight: 600;
}

.face-suggestion-meta .badge-confidence {
  background: #fef3c7;
  color: #d97706;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  border: 1px solid #fde68a;
}

.face-suggestion-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
}

.face-suggestion-actions button {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.face-suggestion-actions button:hover {
  opacity: 0.9;
}

.face-suggestion-actions button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.face-suggestion-actions .btn-approve {
  background: var(--success, #10b981);
  color: #fff;
}

.face-suggestion-actions .btn-reject {
  background: var(--muted-bg, #f1f5f9);
  color: var(--muted, #64748b);
  border: 1px solid var(--border);
}

.face-suggestion-actions .btn-reject:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* ─── Phòng ban Tree (Accordion) ────────────────────────────────────────── */

.dept-tree-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Accordion phòng ban lớn */
.dept-accordion {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow .18s;
}

.dept-accordion:hover {
  box-shadow: 0 4px 16px rgba(15, 23, 42, .08);
}

.dept-accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: filter .15s;
  gap: 12px;
}

.dept-accordion-header:hover {
  filter: brightness(0.96);
}

.dept-accordion-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.dept-accordion-icon {
  font-size: 11px;
  color: var(--muted);
  transition: transform .18s;
  flex-shrink: 0;
}

.dept-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,.8), 0 0 0 3px currentColor;
}

.dept-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.dept-badge {
  font-size: 11px;
  background: rgba(15, 23, 42, .06);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}

.dept-member-badge {
  font-size: 11px;
  background: #dbeafe;
  color: #1d4ed8;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.dept-accordion-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.dept-accordion-body {
  border-top: 1px solid var(--border);
  background: #fafbff;
}

/* Phòng ban con */
.dept-child-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px 9px 32px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  transition: background .15s;
}

.dept-child-item:last-of-type {
  border-bottom: none;
}

.dept-child-item:hover {
  background: #eff6ff;
}

.dept-child-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.dept-child-icon {
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
  font-family: monospace;
}

.dept-child-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dept-child-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Nút nhỏ trong cây phòng ban */
.dept-btn-add-child {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #86efac;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
}

.dept-btn-add-child:hover {
  background: #dcfce7;
  box-shadow: none;
}

.dept-btn-edit {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fcd34d;
  padding: 5px 10px;
  font-size: 12px;
}

.dept-btn-edit:hover {
  background: #fef3c7;
  box-shadow: none;
}

.dept-btn-delete {
  background: transparent;
  color: var(--danger);
  border: 1px solid #fca5a5;
  padding: 5px 10px;
  font-size: 12px;
}

.dept-btn-delete:hover {
  background: #fee2e2;
  box-shadow: none;
}

.dept-btn-filter {
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #7dd3fc;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
}

.dept-btn-filter:hover {
  background: #e0f2fe;
  box-shadow: none;
}

.dept-btn-link {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
}

.dept-btn-link:hover {
  background: var(--primary-h);
}

.dept-btn-members {
  background: #f5f3ff;
  color: #7c3aed;
  border: 1px solid #c4b5fd;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
}

.dept-btn-members:hover {
  background: #ede9fe;
  box-shadow: none;
}

/* Responsive dept tree */
@media (max-width: 640px) {
  .dept-accordion-header {
    flex-wrap: wrap;
  }

  .dept-child-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px 10px 24px;
  }

  .dept-child-actions {
    width: 100%;
  }
}

/* ─── Leave Request Tab ─────────────────────────────────────────────────── */
.leave-table-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

.leave-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  min-width: 1200px;
}

.leave-table thead th {
  background: linear-gradient(180deg, #f1f5f9 0%, #e8edf5 100%);
  padding: 10px 12px;
  font-weight: 700;
  color: #334155;
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid #cbd5e1;
  position: sticky;
  top: 0;
  z-index: 5;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.leave-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

.leave-table tbody tr:hover {
  background: #f8fafc;
}

.leave-table tbody tr.leave-row-done {
  opacity: 0.7;
}

.leave-cell-name {
  font-weight: 600;
  white-space: nowrap;
}

.leave-cell-dates {
  white-space: nowrap;
  font-weight: 500;
  color: #1e40af;
}

.leave-cell-center {
  text-align: center;
}

.leave-cell-reason {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leave-cell-deducted {
  display: flex;
  align-items: center;
  gap: 4px;
}

.leave-deducted-input {
  width: 70px !important;
  min-width: 60px;
  padding: 5px 8px !important;
  font-size: 13px !important;
  text-align: center;
  border-radius: 8px !important;
}

.leave-save-deducted {
  padding: 4px 8px !important;
  font-size: 12px !important;
  border-radius: 6px !important;
  background: #f1f5f9;
  border: 1px solid #cbd5e1 !important;
  cursor: pointer;
  transition: background .15s;
}

.leave-save-deducted:hover {
  background: #dbeafe;
}

.leave-cell-actions {
  white-space: nowrap;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.leave-cell-actions .btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.leave-cell-actions .btn-success {
  background: var(--success);
  color: #fff;
  border: none;
}

.leave-cell-actions .btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 4px 10px;
  font-size: 12px;
}

/* Leave badges */
.leave-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.4;
}

.leave-badge-pending {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.leave-badge-manager {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.leave-badge-approved {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.leave-badge-rejected {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.leave-badge-annual {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
}

.leave-badge-unpaid {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #94a3b8;
}

/* Responsive leave table */
@media (max-width: 860px) {
  .leave-table {
    min-width: 900px;
  }
}

/* Tab Badge style */
.tab-badge {
  background-color: var(--danger);
  color: #fff;
  border-radius: 50%;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 4px;
}

