/* ==========================================================================
   KEYMASTER KMS & VISITOR MANAGEMENT SYSTEM - ULTRA-MODERN PRO UI
   World-class enterprise SaaS aesthetic: Inter/Jakarta typography,
   Glassmorphism, Ambient Gradients, Bento-grid KPI cards, Micro-interactions
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Brand Primary - Electric Indigo & Royal Blue */
  --primary: #3b82f6;
  --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #2563eb 100%);
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-glow: rgba(79, 70, 229, 0.35);

  /* Status Colors */
  --success: #10b981;
  --success-gradient: linear-gradient(135deg, #059669 0%, #10b981 100%);
  --success-light: #ecfdf5;
  --success-border: #a7f3d0;
  
  --warning: #f59e0b;
  --warning-gradient: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  --warning-light: #fffbeb;
  --warning-border: #fde68a;
  
  --danger: #ef4444;
  --danger-gradient: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  --danger-light: #fef2f2;
  --danger-border: #fecaca;
  
  --purple: #8b5cf6;
  --purple-gradient: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
  --purple-light: #f5f3ff;

  /* Neutrals & Slate Scale */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  
  /* Geometry & Shadows */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.03), 0 0 0 1px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.03), 0 0 0 1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  
  /* Animation Timing */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #f8fafc;
  background-image: 
    radial-gradient(at 100% 0%, rgba(99, 102, 241, 0.05) 0px, transparent 50%),
    radial-gradient(at 0% 100%, rgba(59, 130, 246, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--slate-800);
  line-height: 1.55;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--primary-hover);
}

/* ===========================================================
   TOP NAVIGATION - Frosted Glass Luxury Bar
   =========================================================== */
.navbar {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
}

.nav-container {
  max-width: 1520px;
  margin: 0 auto;
  padding: 0.85rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--slate-900);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand:hover {
  color: var(--slate-900);
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #4f46e5 0%, #2563eb 50%, #06b6d4 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 1.35rem;
  box-shadow: 0 8px 18px -2px rgba(79, 70, 229, 0.4);
  transition: transform 0.2s var(--ease-spring);
}

.brand:hover .brand-icon {
  transform: scale(1.05) rotate(-3deg);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(241, 245, 249, 0.7);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border-radius: 9px;
  color: var(--slate-600);
  font-weight: 600;
  font-size: 0.88rem;
  transition: all 0.18s ease;
  position: relative;
}

.nav-link:hover {
  color: var(--slate-900);
  background: rgba(255, 255, 255, 0.7);
}

.nav-link.active {
  background: #ffffff;
  color: #2563eb;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Officer on Duty Badge */
.officer-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--slate-200);
  padding: 0.45rem 0.9rem;
  border-radius: 9999px;
  font-size: 0.84rem;
  color: var(--slate-700);
  box-shadow: var(--shadow-xs);
  transition: all 0.2s ease;
}

.officer-badge:hover {
  background: #ffffff;
  border-color: var(--slate-300);
  box-shadow: var(--shadow-sm);
}

.officer-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  position: relative;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseRadar 2s infinite;
}

@keyframes pulseRadar {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ===========================================================
   MAIN LAYOUT & STAT CARDS (Bento Grid)
   =========================================================== */
.container {
  max-width: 1520px;
  margin: 0 auto;
  padding: 1.75rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: #ffffff;
  border-radius: var(--radius);
  border: 1px solid rgba(226, 232, 240, 0.9);
  padding: 1.35rem 1.45rem;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.25s var(--ease-spring);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  transition: all 0.25s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: rgba(99, 102, 241, 0.3);
}

.stat-card:hover::before {
  background: var(--primary-gradient);
}

.stat-title {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--slate-400);
  margin-top: 0.35rem;
  font-weight: 500;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  transition: transform 0.25s var(--ease-spring);
  flex-shrink: 0;
}

.stat-card:hover .stat-icon {
  transform: scale(1.1) rotate(4deg);
}

.stat-icon.blue   { background: #eff6ff; color: #2563eb; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15); }
.stat-icon.green  { background: #ecfdf5; color: #10b981; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15); }
.stat-icon.orange { background: #fff7ed; color: #f97316; box-shadow: 0 4px 12px rgba(249, 115, 22, 0.15); }
.stat-icon.red    { background: #fef2f2; color: #ef4444; box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15); }
.stat-icon.purple { background: #faf5ff; color: #a855f7; box-shadow: 0 4px 12px rgba(168, 85, 247, 0.15); }

/* ===========================================================
   ALERT BANNERS & NOTIFICATIONS
   =========================================================== */
.pending-alert-banner {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 1.1rem 1.4rem;
  margin-bottom: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  box-shadow: 0 8px 20px -4px rgba(245, 158, 11, 0.15);
  animation: pulseGlow 2.5s infinite alternate;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 8px 20px -4px rgba(245, 158, 11, 0.12); }
  100% { box-shadow: 0 8px 26px -2px rgba(245, 158, 11, 0.25); border-color: #facc15; }
}

.pulse-badge {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: white;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.35);
  letter-spacing: 0.03em;
}

/* ===========================================================
   CONTROLS, SEARCH, AND FILTERS
   =========================================================== */
.controls-card {
  background: #ffffff;
  border-radius: var(--radius);
  border: 1px solid rgba(226, 232, 240, 0.9);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow);
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
  flex: 1;
}

.search-input-wrap {
  position: relative;
  min-width: 280px;
  flex: 1;
}

.search-input-wrap input {
  width: 100%;
  padding: 0.68rem 0.85rem 0.68rem 2.4rem;
  border: 1px solid var(--slate-300);
  border-radius: 11px;
  font-size: 0.93rem;
  font-family: inherit;
  background-color: var(--slate-50);
  outline: none;
  transition: all 0.2s ease;
}

.search-input-wrap input:focus {
  background-color: #ffffff;
  border-color: #4f46e5;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-400);
  pointer-events: none;
  font-size: 0.95rem;
}

.select-custom {
  padding: 0.68rem 2.2rem 0.68rem 0.9rem;
  border: 1px solid var(--slate-300);
  border-radius: 11px;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  background-color: var(--slate-50);
  color: var(--slate-700);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2364748B%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.4-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem top 50%;
  background-size: 0.65rem auto;
  transition: all 0.2s ease;
}

.select-custom:focus {
  background-color: #ffffff;
  border-color: #4f46e5;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

/* ===========================================================
   BUTTON SYSTEM - Modern Gradients & Micro-interactions
   =========================================================== */
.btn-group {
  display: flex;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1.15rem;
  border-radius: 11px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s var(--ease-spring);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  user-select: none;
}

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

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
  color: #ffffff;
}

.btn-success {
  background: var(--success-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
  transform: translateY(-1px);
  color: #ffffff;
}

.btn-danger {
  background: var(--danger-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.45);
  transform: translateY(-1px);
  color: #ffffff;
}

.btn-outline {
  background: #ffffff;
  border-color: var(--slate-300);
  color: var(--slate-700);
}

.btn-outline:hover {
  background: var(--slate-100);
  color: var(--slate-900);
  border-color: var(--slate-400);
}

.btn-sm {
  padding: 0.42rem 0.8rem;
  font-size: 0.82rem;
  border-radius: 8px;
}

/* ===========================================================
   SEGMENTED VIEW SWITCHER TABS & PILLS
   =========================================================== */
.tabs-container {
  display: flex;
  border-bottom: 2px solid var(--slate-200);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  white-space: nowrap;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.85rem 1.25rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--slate-500);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab-btn:hover {
  color: var(--slate-900);
}

.tab-btn.active {
  color: #2563eb;
  font-weight: 700;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-gradient);
  border-radius: 3px 3px 0 0;
}

/* Building Horizontal Pills */
.building-pills {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.65rem;
  margin-bottom: 1.25rem;
}

.building-pills::-webkit-scrollbar {
  height: 5px;
}
.building-pills::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 4px;
}

.pill-btn {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: 9999px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-700);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s var(--ease-spring);
  box-shadow: var(--shadow-xs);
}

.pill-btn:hover {
  border-color: var(--slate-400);
  background: var(--slate-50);
  transform: translateY(-1px);
}

.pill-btn.active {
  background: var(--slate-900);
  color: #ffffff;
  border-color: var(--slate-900);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
}

/* ===========================================================
   KEY CARDS GRID - Sleek Micro-Card Design
   =========================================================== */
.keys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 1.25rem;
}

.key-card {
  background: #ffffff;
  border-radius: var(--radius);
  border: 1px solid rgba(226, 232, 240, 0.95);
  padding: 1.35rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: all 0.25s var(--ease-spring);
  overflow: hidden;
}

.key-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 5px;
  background: transparent;
  transition: all 0.2s ease;
}

.key-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: rgba(99, 102, 241, 0.3);
}

.key-card.status-available::before {
  background: var(--success);
}
.key-card.status-issued::before {
  background: var(--warning);
}
.key-card.status-overdue::before {
  background: var(--danger);
}

.key-card.status-issued {
  background: linear-gradient(180deg, #ffffff 0%, #fffdf8 100%);
}

.key-card.status-overdue {
  background: linear-gradient(180deg, #ffffff 0%, #fff7f7 100%);
  animation: pulseOverdue 2s infinite alternate;
}

@keyframes pulseOverdue {
  0% { box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.1); }
  100% { box-shadow: 0 8px 16px -2px rgba(239, 68, 68, 0.2); }
}

.key-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.key-code {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--slate-900);
  background: var(--slate-100);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--slate-200);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-available {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.badge-issued {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.badge-overdue {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  animation: blink 1.2s infinite;
}

.badge-maintenance {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.key-room-name {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--slate-900);
  margin-bottom: 0.4rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.key-location {
  font-size: 0.86rem;
  color: var(--slate-600);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.key-hook {
  display: inline-block;
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  color: var(--slate-700);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: 6px;
}

/* Borrower Information Box */
.holder-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 0.85rem;
  margin-top: 0.85rem;
  margin-bottom: 0.85rem;
  font-size: 0.84rem;
}

.holder-title {
  font-weight: 800;
  color: #92400e;
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.holder-detail {
  color: #78350f;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.holder-row {
  display: flex;
  justify-content: space-between;
}

.key-card-footer {
  border-top: 1px solid var(--slate-100);
  padding-top: 0.85rem;
  margin-top: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

/* ===========================================================
   MODALS & DIALOGS - High-End Frosted Glass Popups
   =========================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.25rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s var(--ease-spring);
  overflow-y: auto;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: #ffffff;
  border-radius: 22px;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.2);
  overflow: hidden;
  transform: translateY(20px) scale(0.96);
  transition: all 0.25s var(--ease-spring);
  max-height: min(92vh, calc(100vh - 2rem));
  display: flex;
  flex-direction: column;
  margin: auto;
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.modal-card form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  margin: 0;
}

.modal-overlay.open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: #ffffff;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--slate-900);
  letter-spacing: -0.01em;
}

.modal-close {
  background: var(--slate-100);
  border: none;
  font-size: 1.3rem;
  color: var(--slate-500);
  cursor: pointer;
  line-height: 1;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.modal-close:hover {
  background: var(--slate-200);
  color: var(--slate-900);
  transform: rotate(90deg);
}

.modal-body {
  padding: 1.5rem 1.75rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.modal-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.modal-footer {
  padding: 1rem 1.75rem;
  border-top: 1px solid var(--slate-200);
  display: flex;
  justify-content: flex-end;
  gap: 0.85rem;
  background: var(--slate-50);
  flex-shrink: 0;
}

/* ===========================================================
   FORM STYLES - Crisp, High-Contrast Floating Inputs
   =========================================================== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--slate-700);
  margin-bottom: 0.45rem;
}

.form-label .required {
  color: var(--danger);
  font-weight: 800;
}

.form-control {
  width: 100%;
  padding: 0.72rem 0.95rem;
  border: 1px solid var(--slate-300);
  border-radius: 11px;
  font-size: 0.94rem;
  font-family: inherit;
  outline: none;
  background: #ffffff;
  transition: all 0.2s ease;
  color: var(--slate-800);
}

.form-control:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem;
}

.form-hint {
  font-size: 0.77rem;
  color: var(--slate-500);
  margin-top: 0.35rem;
}

/* ===========================================================
   TABLES - Sleek, Enterprise Grade Layout
   =========================================================== */
.table-card {
  background: #ffffff;
  border-radius: var(--radius);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.91rem;
  text-align: left;
}

thead th {
  background: var(--slate-50);
  color: var(--slate-600);
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--slate-200);
  white-space: nowrap;
}

tbody td {
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--slate-100);
  color: var(--slate-800);
  vertical-align: middle;
}

tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr:hover {
  background: #f8fafc;
}

/* ===========================================================
   TOAST NOTIFICATIONS
   =========================================================== */
#toast-container {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  border-left: 4px solid #3b82f6;
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(226, 232, 240, 0.8);
  padding: 0.95rem 1.35rem;
  min-width: 300px;
  max-width: 440px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  animation: toastSlideIn 0.3s var(--ease-spring);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--slate-800);
}

@keyframes toastSlideIn {
  from { transform: translateX(110%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-danger  { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }

/* ===========================================================
   EMPTY STATES & QR STANDEE
   =========================================================== */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--slate-500);
}

.empty-icon {
  font-size: 3.2rem;
  margin-bottom: 0.85rem;
  opacity: 0.7;
}

.empty-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--slate-800);
  margin-bottom: 0.35rem;
}

.qr-preview-box {
  background: var(--slate-50);
  border: 2px dashed var(--slate-300);
  border-radius: 16px;
  padding: 1.75rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.qr-canvas-holder {
  background: #ffffff;
  padding: 1.25rem;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  display: inline-block;
  margin-bottom: 0.85rem;
}

/* ===========================================================
   CUSTOM BACKGROUND PHOTO ENGINE (BG LOADER COMPATIBILITY)
   =========================================================== */
#app-bg-layer {
  position: fixed;
  inset: -20px;
  width: calc(100vw + 40px);
  height: calc(100vh + 40px);
  z-index: -2;
  pointer-events: none;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  transition: filter 0.35s ease, transform 0.35s ease;
  display: none;
}

#app-bg-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  transition: background-color 0.35s ease;
  display: none;
}

body.has-custom-bg {
  background-color: transparent !important;
}

body.has-custom-bg .navbar {
  background: rgba(255, 255, 255, 0.88) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.08);
}

body.has-custom-bg .controls-card,
body.has-custom-bg .table-card,
body.has-custom-bg .stat-card,
body.has-custom-bg .key-card,
body.has-custom-bg .sheet-preview-card,
body.has-custom-bg .tabs-container,
body.has-custom-bg .building-pills {
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.75) !important;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.1) !important;
}

body.has-custom-bg .modal-card {
  background: rgba(255, 255, 255, 0.96) !important;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.85) !important;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.3) !important;
}

/* ===========================================================
   RESPONSIVE DESIGN (Mobile & Tablets)
   =========================================================== */
@media (max-width: 900px) {
  .nav-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }
  .nav-links {
    overflow-x: auto;
    width: 100%;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  .search-input-wrap {
    min-width: 100%;
  }
  .container {
    padding: 1rem;
  }
}
