/* Reset & Base */
:root {
  --bg-color: #0F1219;
  --panel-bg: rgba(25, 30, 41, 0.65);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text-primary: #FFFFFF;
  --text-secondary: #94A3B8;
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --success: #10B981;
  --danger: #EF4444;
  --input-bg: rgba(15, 18, 25, 0.6);
  --radius: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  overflow: hidden;
  /* Tablet app feel */
}

h1,
h2,
h3 {
  font-family: 'Outfit', sans-serif;
}

.app-container {
  height: 100vh;
  height: 100dvh;
  /* Dynamic viewport height for mobile */
  width: 100vw;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Top Bar */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 100;
  pointer-events: none;
  /* Allow clicks to pass through to content below */
}

.top-bar .header-left {
  pointer-events: auto;
  /* Re-enable clicks for buttons and controls */
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.logo i {
  color: var(--primary);
  font-size: 1.5rem;
}

.top-controls {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 101;
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: auto;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.datetime-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 35px;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  opacity: 0.9;
}

.date-display {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: inherit;
  font-weight: 500;
}

.clock-display {
  font-size: 1rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Header Tabs (PC Friendly) */
.header-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: auto;
}

.header-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: 0.2s;
}

.header-tab-btn i {
  font-size: 1.1rem;
}

.header-tab-btn:hover {
  color: white;
}

.header-tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Screen Layout */
.screen {
  flex: 1;
  display: none;
  height: 100%;
}

.screen.active {
  display: block;
}

/* QR Scanner */
.scanner-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
}

.bulk-toggle-panel {
  position: absolute;
  bottom: 24px;
  left: 24px;
  background: rgba(15, 18, 25, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 10px 16px;
  border-radius: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 100;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  pointer-events: auto;
}

.bulk-toggle-panel span {
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
}

.bulk-toggle-panel i {
  color: var(--primary);
  font-size: 1.1rem;
}

.cart-fab {
  position: absolute;
  bottom: 24px;
  right: 24px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.5);
  cursor: pointer;
  z-index: 100;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}

.cart-fab:hover {
  transform: translateY(-4px);
  background: var(--primary-hover);
}

.cart-fab.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
}

.cart-icon-wrapper {
  position: relative;
  font-size: 1.4rem;
}

#cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #EF4444;
  color: white;
  font-size: 0.7rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.bulk-keys-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
}

.bulk-key-tag {
  background: rgba(59, 130, 246, 0.15);
  color: #93C5FD;
  padding: 8px 14px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.bulk-key-tag i {
  font-size: 1rem;
}

#reader {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#reader video {
  min-width: 100%;
  min-height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.camera-switch-btn {
  position: absolute;
  top: 100px;
  right: 24px;
  background: rgba(15, 18, 25, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 100;
  pointer-events: auto;
  transition: 0.2s;
}

.camera-switch-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.scanner-frame {
  width: 250px;
  height: 250px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 24px;
  position: relative;
  box-shadow: 0 0 0 4000px rgba(15, 18, 25, 0.7);
  /* Dark overlay around scanner */
  pointer-events: none;
}

.scanner-frame::before,
.scanner-frame::after {
  content: '';
  position: absolute;
  width: 30px;
  height: 30px;
  border-color: var(--primary);
  border-style: solid;
}

.scanner-frame::before {
  top: -2px;
  left: -2px;
  border-width: 4px 0 0 4px;
  border-radius: 24px 0 0 0;
}

.scanner-frame::after {
  bottom: -2px;
  right: -2px;
  border-width: 0 4px 4px 0;
  border-radius: 0 0 24px 0;
}

.scanner-text {
  margin-top: 40px;
  text-align: center;
  z-index: 2;
}

.scanner-text h2 {
  margin-bottom: 8px;
  font-size: 1.5rem;
}

.scanner-text p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.scan-toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(16, 185, 129, 0.95);
  color: white;
  padding: 14px 28px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 1.1rem;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  justify-content: center;
}

.scan-toast i {
  font-size: 1.5rem;
}

.scan-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.scan-toast.error {
  background: rgba(239, 68, 68, 0.95);
  box-shadow: 0 8px 32px rgba(239, 68, 68, 0.4);
}

/* Glassmorphism Bottom Sheet */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2700;
  max-height: 95vh;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.bottom-sheet.open {
  transform: translateY(0);
  pointer-events: auto;
}

.glass {
  background: var(--panel-bg);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--panel-border);
  border-radius: 28px 28px 0 0;
  /* Mobile feel */
  padding: 32px;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 90vh;
  position: relative;
  display: block;
}

.close-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  color: white;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: 0.2s;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Key Header */
.key-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.key-icon-large {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.05));
  border: 1px solid rgba(59, 130, 246, 0.3);
  display: grid;
  place-items: center;
  font-size: 2rem;
  color: var(--primary);
}

.key-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#key-id-display {
  font-size: 2rem;
  margin-top: 4px;
}

.status-badge {
  margin-left: auto;
  padding: 8px 16px;
  border-radius: 40px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-badge.in {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.out {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.reserved {
  background: rgba(245, 158, 11, 0.15); /* amber-500 */
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Action Section */
.action-section h3 {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.action-buttons {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.action-btn {
  flex: 1;
  padding: 16px;
  border: none;
  border-radius: 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: 0.2s;
}

.action-btn.primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

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

.action-btn.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.action-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.action-btn.secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-btn.danger {
  background: rgba(239, 68, 68, 0.12);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
  margin-top: 12px;
  width: 100%;
}

.action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.action-btn.danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Form */
.form-section {
  background: rgba(0, 0, 0, 0.2);
  padding: 24px;
  border-radius: 20px;
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.form-section h3 {
  margin-bottom: 20px;
  font-size: 1.1rem;
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper i {
  position: absolute;
  left: 16px;
  color: var(--text-secondary);
  pointer-events: none;
}

input[type="date"],
input[type="datetime-local"] {
  position: relative;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.input-wrapper input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px 14px 14px 44px;
  color: white;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: 0.2s;
}

.input-wrapper input:focus {
  border-color: var(--primary);
}

.submit-btn {
  width: 100%;
  padding: 16px;
  background: white;
  color: black;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
  margin-top: 8px;
  cursor: pointer;
  transition: 0.2s;
}

.submit-btn:hover {
  background: #e2e8f0;
}

.cancel-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  font-size: 0.9rem;
  margin-top: 8px;
  cursor: pointer;
}

.history-item {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  margin-bottom: 8px;
}

.hist-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}

.hist-icon.borrow {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.hist-icon.return {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.hist-info {
  flex: 1;
}

.hist-info strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.hist-info span {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  gap: 6px;
  align-items: center;
}

.hist-time {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
  font-family: 'Outfit', sans-serif;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 24px 0;
}

/* Custom HTML5 QR Code Scanner styles to hide defaults */
#reader__dashboard_section_csr span,
#reader__dashboard_section_csr button {
  font-family: inherit;
}

#reader__dashboard_section_swaplink {
  text-decoration: none;
  color: var(--primary);
}

#reader video {
  border-radius: 0;
}

/* Dashboard Area */
#dashboard-screen {
  padding-top: 140px;
  padding-bottom: 40px;
  overflow-y: auto;
  align-items: center;
  flex-direction: column;
}

#dashboard-screen.active {
  display: flex;
}

.dashboard-container {
  width: 100%;
  max-width: 800px;
  padding: 24px;
}

.glass-panel {
  background: rgba(25, 30, 41, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.dashboard-header h2 {
  font-size: 1.5rem;
}

.tabs {
  display: flex;
  gap: 8px;
  background: var(--input-bg);
  padding: 4px;
  border-radius: 12px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs .tab-btn {
  flex: 0 0 auto;
}

.tab-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: 0.2s;
}

.tab-btn i {
  font-size: 1rem;
}

.tab-btn:hover {
  color: white;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* --- Common Typography & Layout Titles --- */
.tab-section-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 24px 0;
  font-family: 'Outfit', sans-serif;
}

.tab-section-title i {
  color: var(--primary);
  font-size: 1.3rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.card-title i {
  color: var(--primary);
  font-size: 1.2rem;
}

.card-title.danger {
  color: var(--danger);
}

.card-title.danger i {
  color: var(--danger);
}

/* Status Controls (2-Row Layout) */
.status-controls-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.controls-row.top-row {
  justify-content: flex-end;
}

.controls-row.bottom-row {
  justify-content: space-between;
}

/* Status Filter Toggle */
.status-filter {
  display: flex;
  gap: 8px;
  background: var(--input-bg);
  padding: 6px;
  border-radius: 14px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.status-filter::-webkit-scrollbar {
  display: none;
}

.status-filter .filter-btn {
  flex: 0 0 auto;
}

.filter-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px 20px;
  font-size: 0.95rem;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s;
  font-family: inherit;
  font-weight: 600;
}

.filter-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Search Bar */
.search-bar-container {
  flex: 1;
  min-width: 250px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--text-secondary);
  font-size: 1.1rem;
  pointer-events: none;
  transition: 0.2s;
}

.search-input-wrapper input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px 16px 12px 48px;
  color: white;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input-wrapper input:focus {
  border-color: var(--primary);
  background: rgba(25, 30, 41, 0.8);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.search-input-wrapper input:focus+.search-icon {
  color: var(--primary);
}

/* Grid for Key Status (Grouped List) */
#status-container {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.group-section {
  width: 100%;
  max-width: 100%;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.group-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding-left: 16px;
  margin-left: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  gap: 12px;
  padding-top: 4px;
  box-sizing: border-box;
  overflow: hidden;
}

.group-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: 0.2s;
  border-radius: 12px;
}

.depth-0>.group-title {
  font-size: 1.2rem;
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.2);
  padding: 14px 20px;
}

.depth-1>.group-title {
  padding-left: 20px;
}

.depth-2>.group-title {
  padding-left: 30px;
}

.depth-3>.group-title {
  padding-left: 40px;
}

.group-title:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.group-name-text {
  margin-left: 10px;
  flex: 1;
}

.group-title i:first-child {
  color: var(--primary);
}

.caret-icon {
  margin-left: auto;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Accordion States */
.group-section.collapsed>.caret-icon {
  transform: rotate(-90deg);
}

.group-section.collapsed>.group-title .caret-icon {
  transform: rotate(-90deg);
}

.group-section.collapsed>.group-content {
  display: none !important;
}

.group-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.key-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 16px 24px;
  border-radius: 16px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.key-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateX(6px);
}

.kc-header {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 160px;
}

.kc-id {
  font-size: 1.1rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}

.kc-id i {
  color: var(--primary);
  font-size: 1.2rem;
}

.kc-body {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 20px;
}

.kc-body span {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.kc-body strong {
  color: white;
  font-size: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .key-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .kc-body {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

/* Key Group UI in Panel */
.key-group-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin-top: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  width: fit-content;
  transition: 0.2s;
}

.key-group-row:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.key-group-row .edit-icon {
  font-size: 0.8rem;
  opacity: 0.6;
}

/* Login Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  transition: 0.3s;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.login-box {
  width: 90%;
  max-width: 400px;
  padding: 40px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.login-icon-large {
  width: 72px;
  height: 72px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  border-radius: 20px;
  display: grid;
  place-items: center;
  margin: 0 auto 24px;
  font-size: 2.2rem;
}

.login-header h2 {
  font-size: 1.5rem;
  color: white;
  margin-bottom: 8px;
}

.login-header p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

.login-error {
  color: #fb7185;
  font-size: 0.85rem;
  margin-bottom: 8px;
  background: rgba(251, 113, 133, 0.1);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(251, 113, 133, 0.2);
}

.login-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 30px;
}

.login-actions .submit-btn {
  width: 100%;
  font-size: 1rem;
  padding: 14px;
}

.login-actions .cancel-btn {
  width: 100%;
  background: transparent;
  color: var(--text-secondary);
}

.login-actions .cancel-btn:hover {
  color: white;
}

/* Global History List */
.history-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 20px;
}

#download-csv-btn {
  padding: 10px 20px;
  font-size: 0.9rem;
  border-radius: 12px;
  width: auto;
  flex: none;
}

.global-history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Login Settings Tab */
.settings-header {
  margin-bottom: 24px;
}

.settings-header h3 {
  font-size: 1.1rem;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.settings-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.user-slot {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 16px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.slot-number {
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.slot-inputs {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.slot-inputs input {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 12px;
  color: white;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: 0.2s;
  width: 100%;
}

.slot-inputs input:focus {
  border-color: var(--primary);
  background: rgba(0, 0, 0, 0.3);
}

@media (max-width: 600px) {
  .user-slot {
    flex-direction: column;
    align-items: flex-start;
  }

  .slot-inputs {
    grid-template-columns: 1fr;
    width: 100%;
  }
}

/* --- Lock Screen Specifics --- */
.lock-wrapper {
  background: #000000;
}

.lock-frame {
  border-color: #EF4444;
  box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.85);
}

.locked-tab {
  opacity: 0.3 !important;
  pointer-events: none;
}

/* --- Toggle Switch --- */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
  border-radius: 28px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--primary);
}

input:checked+.slider:before {
  transform: translateX(22px);
}

/* --- System Settings Card --- */
.system-settings-card {
  padding: 24px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  box-sizing: border-box;
}

/* --- Admin Data Edit Sub-Navigation --- */
.edit-tab-nav {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: fit-content;
  margin-bottom: 24px;
}

.edit-nav-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.edit-nav-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.setting-info strong {
  display: block;
  color: white;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.setting-info p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.hist-memo {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --- Mobile Specific Enhancements (Android/iPhone/Tablet) --- */
@media (max-width: 992px) {
  body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }

  /* Compact Top Bar on Mobile */
  .top-bar {
    padding: 12px 16px;
    background: linear-gradient(to bottom, rgba(15, 18, 25, 0.95), rgba(15, 18, 25, 0.7));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    height: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }

  .logo {
    font-size: 1.15rem;
  }

  .datetime-container {
    display: flex !important;
    position: absolute;
    top: 12px;
    right: 16px;
    flex-direction: column;
    align-items: flex-end;
    gap: 0px;
    margin-left: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  }

  .date-display {
    font-size: 0.65rem;
    color: var(--text-secondary);
  }

  .clock-display {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
  }

  /* Bottom Navigation Bar for PWA/Mobile Touch Optimization */
  .top-controls {
    position: fixed;
    top: auto !important;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 18, 25, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 12px;
    /* Prevent overlaps with system buttons (iOS Home indicator / Android bottom navigation) */
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 20px));
    z-index: 2500;
    justify-content: center;
    pointer-events: auto;
    display: flex;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
  }

  .header-tabs {
    width: 100%;
    max-width: 480px;
    background: transparent;
    border: none;
    display: flex;
    justify-content: space-around;
    padding: 0;
    gap: 4px;
  }

  .header-tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 0;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 8px;
    background: transparent;
    box-shadow: none !important;
    transition: all 0.2s;
  }

  .header-tab-btn i {
    font-size: 1.4rem; /* Larger icon for bottom nav bar */
  }

  .header-tab-btn.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary);
  }

  /* Position floating actions nicely above the bottom navigation bar */
  .bulk-toggle-panel {
    bottom: calc(75px + env(safe-area-inset-bottom, 20px)) !important;
    left: 16px;
    padding: 8px 14px;
    background: rgba(15, 18, 25, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  }

  .cart-fab {
    bottom: calc(75px + env(safe-area-inset-bottom, 20px)) !important;
    right: 16px;
    padding: 10px 18px;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
  }

  /* Move camera-switch-btn below the mobile top bar and adjust size */
  .camera-switch-btn {
    top: calc(75px + env(safe-area-inset-top, 0px)) !important;
    right: 16px !important;
    width: 44px !important;
    height: 44px !important;
    font-size: 1.3rem !important;
  }

  /* Bottom sheet style adjustments */
  .glass {
    padding: 24px 20px calc(80px + env(safe-area-inset-bottom, 20px)) 20px;
    border-radius: 28px 28px 0 0;
    max-height: 80vh;
    max-height: 80dvh;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    display: block;
  }

  .close-btn {
    top: 12px;
    right: 16px;
  }

  /* Screen padding adjustments */
  #dashboard-screen {
    padding-top: 72px;
    /* Extra padding at the bottom so that items are not obscured by the bottom nav */
    padding-bottom: calc(85px + env(safe-area-inset-bottom, 20px));
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .user-profile-display {
    margin-left: 0;
    font-size: 0.8rem;
    padding: 4px 8px;
    margin-top: 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  /* Login Wrapper scrollability when touch keyboard is active */
  .login-wrapper {
    min-height: auto !important;
    height: 100%;
    overflow-y: auto !important;
    align-items: flex-start !important;
    padding-top: 60px !important;
    padding-bottom: 40px !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Mobile container/card padding optimizations to prevent layout overflows */
  .dashboard-container {
    padding: 16px !important;
    border-radius: 16px !important;
  }

  .system-settings-card {
    padding: 16px !important;
  }

  .calendar-header {
    gap: 12px;
  }

  #cal-prev-btn,
  #cal-next-btn {
    padding: 8px 14px;
  }

  #cal-month-year {
    font-size: 1.15rem;
    min-width: 110px;
  }
}

.glass::-webkit-scrollbar {
  width: 6px;
}

.glass::-webkit-scrollbar-track {
  background: transparent;
}

.glass::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

/* Download Buttons Adjustment */
.status-controls-container .controls-row.top-row,
.history-controls {
  text-align: right;
  margin-bottom: 20px;
}

#download-csv-btn,
#download-keys-csv-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto !important;
  flex: none !important;
  align-self: flex-start;
  min-width: 200px;
  padding: 12px 24px !important;
  font-size: 0.95rem !important;
  white-space: nowrap;
}

/* ==========================================================================
   Reservation & Calendar Feature Styles
   ========================================================================== */

.warning-banner {
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateY(0);
  opacity: 1;
}

.warning-banner.hidden {
  display: none !important;
  opacity: 0;
  transform: translateY(-8px);
}

.calendar-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin-bottom: 8px;
}

#cal-prev-btn,
#cal-next-btn {
  width: auto;
  flex: none;
  padding: 10px 20px;
  margin: 0;
  font-size: 0.95rem;
  border-radius: 10px;
}

#cal-month-year {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  min-width: 150px;
  text-align: center;
  white-space: nowrap;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.calendar-day-header {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 8px 0;
  text-transform: uppercase;
}

.calendar-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.95rem;
  font-weight: 500;
  position: relative;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.calendar-cell:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

.calendar-cell.other-month {
  opacity: 0.2;
  cursor: default;
}
.calendar-cell.other-month:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.04);
  transform: none;
}

.calendar-cell.today {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  font-weight: 700;
}

.calendar-cell.reserved {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #f59e0b;
}

.calendar-cell.reserved::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  position: absolute;
  bottom: 8px;
}

/* Reservation list item */
.reservation-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  margin-bottom: 8px;
  transition: background 0.2s;
}

.reservation-list-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.res-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.res-period {
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  font-family: 'Outfit', sans-serif;
}

.res-user {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.res-delete-btn {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.res-delete-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  transform: scale(1.05);
}

/* Responsive adjustments for reservation grid */
@media (max-width: 900px) {
  .reservation-grid-layout {
    grid-template-columns: 1fr !important;
  }
}

/* Bottom Grid for Reservation Form and List */
.reservation-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 768px) {
  .reservation-bottom-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Select Option White-Background Styling for Max Readability */
select option {
  background-color: #ffffff !important;
  color: #1f2937 !important;
}

/* Custom Searchable Select Styles */
.custom-select-container {
  position: relative;
  width: 100%;
}

.custom-select-trigger-wrapper {
  position: relative;
  width: 100%;
}

.custom-select-trigger-wrapper input {
  cursor: pointer;
  padding-right: 44px !important;
}

.custom-select-trigger-wrapper .caret-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-secondary);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 1.1rem;
}

.custom-select-container.open .caret-icon {
  transform: translateY(-50%) rotate(180deg);
  color: var(--primary);
}

.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  padding: 8px;
  background: rgba(20, 25, 35, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  box-sizing: border-box;
}

.custom-select-container.open .custom-select-dropdown {
  display: block;
  animation: selectDropdownFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes selectDropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.custom-select-options-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.custom-select-option {
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.custom-select-option:hover,
.custom-select-option.keyboard-hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.custom-select-option.selected {
  background: var(--primary);
  color: white;
}

.custom-select-option .option-id {
  font-weight: 600;
  color: white;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
}

.custom-select-option.selected .option-id {
  color: white;
}

.custom-select-option .option-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.custom-select-option.selected .option-meta {
  color: rgba(255, 255, 255, 0.8);
}

.custom-select-no-results {
  padding: 16px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-align: center;
}

/* User Profile & Login Screen styles (MonoModor v3.1) */
.user-profile-display {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-left: 35px;
  margin-top: 6px;
  width: fit-content;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.active-user-info-banner {
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 12px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 20px;
  box-sizing: border-box;
  width: 100%;
}


/* --- Password Change Feature Custom Styles --- */
.user-profile-display {
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.user-profile-display:hover {
  transform: translateY(-1px);
}
.user-profile-display:hover span {
  text-decoration: underline;
}
.user-profile-display:hover .profile-key-icon {
  opacity: 1 !important;
  color: var(--primary) !important;
}

/* Modal Overlay & Animations */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 12, 18, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-overlay .modal-content {
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.open .modal-content {
  transform: scale(1);
}

/* Profile Edit Modal Content default & mobile styling */
.profile-edit-modal-content {
  max-width: 420px;
  padding: 24px 24px 32px 24px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(25, 30, 41, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-sizing: border-box;
  width: 92%;
  max-height: 80vh;
  max-height: 80dvh;
  overflow-y: auto;
}

/* Login QR Scanner Styles */
.login-scanner-wrapper {
  position: relative;
  width: 100%;
  max-width: 260px;
  height: 260px;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.login-scanner-wrapper #reader-login {
  width: 100%;
  height: 100%;
}

.login-scanner-wrapper #reader-login video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

.login-scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
}

.login-scanner-frame {
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  position: relative;
}

.login-scanner-frame .corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: #ef4444; /* 赤に変更 */
  border-style: solid;
}

.login-scanner-frame .corner.tl {
  top: -1px;
  left: -1px;
  border-width: 3px 0 0 3px;
  border-radius: 16px 0 0 0;
}

.login-scanner-frame .corner.tr {
  top: -1px;
  right: -1px;
  border-width: 3px 3px 0 0;
  border-radius: 0 16px 0 0;
}

.login-scanner-frame .corner.bl {
  bottom: -1px;
  left: -1px;
  border-width: 0 0 3px 3px;
  border-radius: 0 0 0 16px;
}

.login-scanner-frame .corner.br {
  bottom: -1px;
  right: -1px;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 16px 0;
}

/* User Profile Display Collapse Styles */
.user-profile-display.collapsed {
  padding: 6px;
  gap: 0;
}

.user-profile-content {
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s ease, max-width 0.3s ease;
  max-width: 300px;
  opacity: 1;
  overflow: hidden;
  min-width: 0;
}

.user-profile-display.collapsed .user-profile-content {
  max-width: 0;
  opacity: 0;
  pointer-events: none;
}

.user-profile-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 2px;
  transition: transform 0.2s ease;
}

.user-profile-toggle:hover {
  transform: scale(1.15);
}

.user-profile-display {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-profile-display:hover {
  transform: translateY(-1px);
}

.user-profile-content:hover span {
  text-decoration: underline;
}

.user-profile-content:hover .profile-key-icon {
  opacity: 1 !important;
  color: var(--primary) !important;
}

/* Calendar and Dial Grid Layout */
.reservation-top-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.calendar-cell.selected-day {
  border-color: var(--primary) !important;
  background: rgba(59, 130, 246, 0.2) !important;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3) !important;
  font-weight: 700;
}

@media (max-width: 900px) {
  .reservation-top-grid {
    grid-template-columns: 1fr;
  }
}

/* Extreme Mobile Screen Optimizations (e.g., iPhone SE/Compact Android) */
@media (max-width: 480px) {
  .dashboard-container {
    padding: 10px !important;
    border-radius: 14px !important;
  }

  .system-settings-card {
    padding: 12px 10px !important;
    border-radius: 12px !important;
  }

  .calendar-grid {
    gap: 4px;
    margin-top: 8px;
  }

  .calendar-cell {
    font-size: 0.85rem;
    border-radius: 8px;
  }

  .calendar-day-header {
    font-size: 0.75rem;
    padding: 6px 0;
  }

  .calendar-header {
    gap: 8px;
  }

  #cal-prev-btn,
  #cal-next-btn {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  #cal-month-year {
    font-size: 1.05rem;
    min-width: 95px;
  }

  .profile-edit-modal-content {
    padding: 20px 20px 28px 20px !important;
    max-height: 75dvh !important;
  }

  /* Compact Login Box for Mobile screens to prevent cutoff/overflow */
  .login-wrapper {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 20px)) !important;
  }

  .login-box {
    padding: 24px 20px !important;
    border-radius: 16px !important;
  }

  .login-icon-large {
    width: 56px !important;
    height: 56px !important;
    margin-bottom: 16px !important;
    font-size: 1.8rem !important;
  }

  .login-header {
    margin-bottom: 20px !important;
  }

  .login-header h2 {
    font-size: 1.3rem !important;
  }

  .login-box .input-group {
    margin-bottom: 14px !important;
  }

  .login-box .submit-btn {
    padding: 12px !important;
    font-size: 0.95rem !important;
  }

  #toggle-guest-login-btn,
  #toggle-registered-login-btn {
    font-size: 0.8rem !important;
  }

  #login-system-repair-btn {
    font-size: 0.75rem !important;
  }
}

