/* 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;
}

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: 100dvh; /* 繧ｹ繝槭・縺ｮ繧｢繝峨Ξ繧ｹ繝舌・蟇ｾ遲・*/
  min-height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Top Bar */
.top-bar {
  position: absolute;
  top: 0;
  width: 100%;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  pointer-events: none;
  /* Allow clicks to pass through to content below */
}

.top-bar .header-left,
.top-bar .top-controls {
  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 {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.datetime-container {
  display: flex;
  flex-direction: column; /* 邵ｦ縺ｮ2谿ｵ邨・↓螟画峩 */
  align-items: flex-start;
  gap: 2px; /* 邵ｦ縺ｮ髢馴囈繧堤強縺上☆繧・*/
  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;
  line-height: 1.1; /* 邵ｦ縺ｮ髫咎俣繧貞ｰ代＠隧ｰ繧√ｋ */
}

/* 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 12px;
  font-size: 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: 0.2s;
  white-space: nowrap;
}

.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;
}

#reader {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

.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;
}

.scanner-frame {
  width: clamp(200px, 60vw, 250px);
  height: clamp(200px, 60vw, 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 */
}

.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;
}

/* Glassmorphism Bottom Sheet */
.bottom-sheet {
  position: fixed; /* 繧ｹ繝槭・逕ｻ髱｢螟悶↓隕句・繧後ｋ縺ｮ繧帝亟縺・*/
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 16px;
  transform: translateY(120%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
  max-height: 90vh;
  display: flex;
  justify-content: center;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.glass {
  background: var(--panel-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  padding: 32px;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  max-height: 85vh;
  position: relative;
}

.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);
}

/* 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;
}

/* 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);
}

.hidden {
  display: none !important;
}

.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);
}

.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 */
.history-section h3 {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.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;
}

/* Hide library's default guide lines (T-shaped white boxes) */
#reader__scan_region > div {
  display: none !important;
}

/* Dashboard Area */
#dashboard-screen {
  padding-top: 120px;
  /* Data content is pushed further down to avoid header overlap */
  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;
}

.tab-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: 0.2s;
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

/* Grid for Key Status (Grouped List) */
#status-tab {
  display: flex;
  flex-direction: column;
  gap: 40px;
  /* 譽滂ｼ医げ繝ｫ繝ｼ繝暦ｼ峨＃縺ｨ縺ｮ髢馴囈 */
}

/* Status Tab Styles */

.group-section {
  width: 100%;
}

.group-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.group-title i {
  color: var(--primary);
}

.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: flex-start; /* Changed from center to allow margin-top control */
  justify-content: center;
  z-index: 3000;
  transition: 0.3s;
  padding: 20px;
  overflow-y: auto;
}

.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 40px 100px rgba(0, 0, 0, 0.8);
  margin-top: 10vh; /* Positioned higher as requested */
}

.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-error.hidden {
  display: none;
}

.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 Tab Styles */

.global-history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Sync Optimization UI */
.search-container {
  margin-bottom: 24px;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrapper i {
  position: absolute;
  left: 20px;
  color: var(--text-secondary);
  font-size: 1.2rem;
}

.search-wrapper input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 16px 16px 16px 54px;
  color: white;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: 0.3s;
}

.search-wrapper input:focus {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.15);
}

.pagination-controls {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.pagination-controls.hidden {
  display: none;
}

.item-count-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Filter Chips Styling */
.filter-chips {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.filter-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 16px;
  border-radius: 50px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: 0.3s;
}

.filter-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.filter-chip.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.filter-chip i {
  font-size: 1rem;
}

.filter-chip[data-filter="out"].active {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

.filter-chip[data-filter="in"].active {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--success);
  color: var(--success);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

/* Login Settings Tab */
/* Settings Tab Styles */

.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-input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slot-input-group label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 4px;
}

.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%;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-with-icon input {
  padding-right: 40px;
}

.toggle-password-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  transition: 0.2s;
  z-index: 2;
}

.toggle-password-btn:hover {
  color: white;
}

.slot-inputs input:focus {
  border-color: var(--primary);
  background: rgba(0, 0, 0, 0.3);
}

.settings-footer {
  padding: 12px;
  background: rgba(59, 130, 246, 0.05);
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}

.settings-footer p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 600px) {
  .user-slot {
    flex-direction: column;
    align-items: flex-start;
  }

  .slot-inputs {
    grid-template-columns: 1fr;
    width: 100%;
  }
}

/* --- v2.2 Lock Screen Styles (Cleaned & Unified) --- */
.lock-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: 0.3s;
  overflow: hidden;
  pointer-events: none;
}

.lock-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-20px);
}

/* Rely on the frame's box-shadow for the dark overlay (guarantees perfect alignment) */

/* Hide background junk when locked to prevent overlapping */
.app-locked .scanner-text,
.app-locked .scanner-tips,
.app-locked .scanner-overlay,
.app-locked .scanner-frame {
  display: none !important;
}

.lock-content, .lock-scanner-frame {
  pointer-events: auto;
}

.lock-content {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 0 32px;
  height: 76px; /* Optimized height */
  border-radius: 16px;
  max-width: 600px;
  width: 90%;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(59, 130, 246, 0.4);
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8), 0 0 20px rgba(59, 130, 246, 0.1);
  z-index: 5010;
}

.lock-icon {
  width: 48px;
  height: 48px;
  font-size: 1.6rem;
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.lock-info-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.lock-info-text h2 {
  font-size: 1.15rem;
  margin: 0;
  color: var(--primary);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  line-height: 1.2;
}

.lock-info-text p {
  font-size: 0.85rem;
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.4;
}

.lock-scanner-frame {
  position: relative;
  width: clamp(200px, 60vw, 250px);
  height: clamp(200px, 60vw, 250px);
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-radius: 24px;
  box-shadow: 0 0 0 4000px rgba(15, 18, 25, 0.85); 
  z-index: 5005;
  animation: scannerPulse 2s infinite ease-in-out;
}

@keyframes scannerPulse {
  0% { box-shadow: 0 0 0 4000px rgba(15, 18, 25, 0.85), 0 0 15px rgba(59, 130, 246, 0.1); border-color: rgba(59, 130, 246, 0.2); }
  50% { box-shadow: 0 0 0 4000px rgba(15, 18, 25, 0.85), 0 0 30px rgba(59, 130, 246, 0.4); border-color: rgba(59, 130, 246, 0.6); }
  100% { box-shadow: 0 0 0 4000px rgba(15, 18, 25, 0.85), 0 0 15px rgba(59, 130, 246, 0.1); border-color: rgba(59, 130, 246, 0.2); }
}

.lock-scanner-frame::before,
.lock-scanner-frame::after {
  content: '';
  position: absolute;
  width: 30px;
  height: 30px;
  border-color: var(--primary);
  border-style: solid;
  filter: drop-shadow(0 0 8px var(--primary));
  z-index: 5006;
}

.lock-scanner-frame::before {
  top: -2px;
  left: -2px;
  border-width: 4px 0 0 4px;
  border-radius: 24px 0 0 0;
}

.lock-scanner-frame::after {
  bottom: -2px;
  right: -2px;
  border-width: 0 4px 4px 0;
  border-radius: 0 0 24px 0;
}

.scanner-dot {
  width: 12px;
  height: 12px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--primary);
  animation: pulse-ring 1.5s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 0.5; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.8); opacity: 0.5; }
}

.tab-header-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px 0 60px 0;
  padding: 0;
}

.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 40px;
  margin-top: 40px;
}

.member-card {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 28px;
  padding: 40px; /* Maximum breathing room */
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.system-admin {
  border: 1px solid rgba(245, 158, 11, 0.45) !important;
  background: rgba(245, 158, 11, 0.04) !important;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4), 0 0 25px rgba(245, 158, 11, 0.15) !important;
}

.member-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 0 15px rgba(59, 130, 246, 0.1);
}

.mc-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mc-avatar {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.2rem;
  color: white;
  box-shadow: 0 5px 15px rgba(59, 130, 246, 0.3);
}

.mc-info {
  flex: 1;
}

.mc-info h4 {
  margin: 0 0 4px 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
}

.mc-id-badge {
  display: inline-block;
  padding: 2px 10px;
  background: rgba(59, 130, 246, 0.2);
  color: var(--primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.mc-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.mc-detail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

.mc-detail-item i {
  color: var(--primary);
  font-size: 1rem;
  width: 16px;
}

.mc-actions {
  position: absolute;
  top: 32px;
  right: 32px;
  display: flex;
  gap: 12px;
}

.mc-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: grid;
  place-items: center;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.6);
  color: rgba(255, 255, 255, 0.45);
  transition: all 0.3s ease;
}

.mc-btn:hover {
  transform: translateY(-2px);
  color: white;
}

.edit-member-btn:hover { background: rgba(59, 130, 246, 0.2); border-color: var(--primary); color: var(--primary); }
.delete-member-btn:hover { background: rgba(239, 68, 68, 0.15); border-color: #ef4444; color: #ef4444; }

.member-add-form {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 32px;
  padding: 48px;
  margin: 40px 0 80px 0; /* Huge vertical spacing */
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
  animation: slideDown 0.4s ease-out;
}

.member-add-form.hidden { display: none; }

.member-add-form .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px; /* Breathing room for inputs */
  margin-bottom: 32px;
}

.hist-icon.unlock { background: rgba(245, 158, 11, 0.1); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.2); }
.gh-icon.unlock { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.history-status.unlock, .gh-action.unlock { color: #fbbf24; background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.2); }

.member-add-form input {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 12px;
  border-radius: 12px;
  color: white;
}

.member-add-form .form-actions {
  display: flex;
  gap: 12px;
}
