@import url('https://fonts.cdnfonts.com/css/sf-pro-display');
@import url('https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap');
@import url('./variables.css');

/* ====================================================
   RESET & GLOBAL BASE STYLES
   ==================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  letter-spacing: -0.012em;
  background-image: none;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .modal-title, .stat-value, .guide-step-title, .diagnostic-title {
  font-family: var(--font-base);
  letter-spacing: -0.025em;
  font-weight: 700;
  color: var(--text-heading);
}

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

/* Hide Scrollbars Globally While Retaining Scrollability */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
::-webkit-scrollbar {
  width: 0px !important;
  height: 0px !important;
  display: none !important;
}

/* ====================================================
   ANT DESIGN ICONS SYSTEM
   ==================================================== */
.anticon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  font-style: normal;
  line-height: 0;
  text-align: center;
  text-transform: none;
  vertical-align: -0.125em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  flex-shrink: 0;
}

.anticon svg,
svg.anticon {
  display: inline-block;
  width: 1em !important;
  height: 1em !important;
  max-width: 1em !important;
  max-height: 1em !important;
  fill: currentColor;
  flex-shrink: 0;
  vertical-align: -0.125em;
}

/* ====================================================
   APP CONTAINER & HEADER
   ==================================================== */
.app-container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  padding: 0.5rem 0.25rem;
  background: transparent;
  border: none;
  box-shadow: none;
  margin-bottom: 1.75rem;
  position: relative;
  width: 100%;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  min-width: 0;
  flex: 1;
}

.brand-logo-glow {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--neu-flat-sm);
  border: 1px solid rgba(255, 255, 255, 0.85);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  transition: var(--transition-fast);
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-family: var(--font-rubik) !important;
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-brand) !important;
  letter-spacing: -0.015em;
  margin: 0;
}

.brand-subtitle {
  font-size: 0.98rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.25rem;
  line-height: 1.35;
}

.header-controls {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.75rem;
  flex-shrink: 0;
  margin-left: auto;
}

/* Live Connection Indicator Dot (Integrated inside User Identity Button) */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--status-available);
  box-shadow: 0 0 8px var(--status-available-glow);
}
.status-dot.offline {
  background: var(--status-overdue);
  box-shadow: 0 0 8px var(--status-overdue-glow);
}

.status-dot.pulse::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  border: 1.5px solid var(--status-available);
  animation: pulse-ring 2s infinite ease-out;
}

@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* User Identity Button (Neumorphic Raised Pill) */
.user-identity-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  height: 38px;
  padding: 0 1rem;
  box-sizing: border-box;
  border-radius: var(--radius-full);
  background: var(--bg-dark);
  box-shadow: var(--neu-flat-sm);
  border: 1px solid rgba(255, 255, 255, 0.85);
  color: var(--text-heading);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
}
.user-identity-btn:hover {
  box-shadow: var(--neu-flat);
  transform: translateY(-1px);
}
.user-identity-btn:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}

/* Notification Button (Circular Soft UI Button) */
.notif-permission-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--bg-dark);
  box-shadow: var(--neu-flat-sm);
  border: 1px solid rgba(255, 255, 255, 0.85);
  color: var(--text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition-fast);
}
.notif-permission-btn:hover {
  color: var(--text-heading);
  box-shadow: var(--neu-flat);
  transform: translateY(-1px);
}
.notif-permission-btn:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}
.notif-permission-btn.active {
  color: var(--status-available);
}
.notif-permission-btn.active:hover {
  color: #059669;
}
.notif-permission-btn.blocked {
  color: var(--status-overdue);
}
.notif-permission-btn.blocked:hover {
  color: #DC2626;
}
.notif-permission-btn.warning {
  color: var(--status-borrowed);
}
.notif-permission-btn.warning:hover {
  color: #D97706;
}
.notif-permission-btn.stale {
  color: var(--status-overdue);
  animation: pulse-stale 2s infinite ease-in-out;
}

@keyframes pulse-icon {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@keyframes pulse-stale {
  0%, 100% { box-shadow: var(--neu-flat-sm); }
  50% { box-shadow: 0 0 12px rgba(239, 68, 68, 0.4); }
}

/* Clear Cache Button (Neumorphic Sculpted Pill) */
.clear-cache-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-full);
  background: var(--bg-dark);
  box-shadow: var(--neu-flat-sm);
  border: 1px solid rgba(255, 255, 255, 0.85);
  color: var(--text-muted);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.clear-cache-btn:hover {
  color: var(--status-overdue);
  box-shadow: var(--neu-flat);
  transform: translateY(-1px);
}
.clear-cache-btn:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}

/* ====================================================
   NOTICE BANNER (NEUMORPHIC RAISED CARD)
   ==================================================== */
.banner-notice {
  background: var(--bg-dark);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-lg);
  padding: 1rem 1.4rem;
  margin-bottom: 1.75rem;
  color: var(--text-main);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: var(--neu-flat-sm);
  line-height: 1.45;
}

.banner-notice strong {
  color: var(--text-heading);
}

.banner-notice-icon {
  font-size: 1.35rem;
  color: var(--primary);
  flex-shrink: 0;
}


/* ====================================================
   FILTER & ACTION TOOLBAR
   ==================================================== */
.toolbar-section {
  display: flex;
  align-items: center;
  width: 100%;
  margin-bottom: 2rem;
}

.search-and-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  width: 100%;
  min-width: 0;
}

.search-box-wrapper {
  position: relative;
  width: 320px;
  max-width: 100%;
  flex-shrink: 0;
  margin-left: auto;
}

/* Inset / Debossed Search Channel matching Reference Image */
.search-box-wrapper input {
  width: 100%;
  padding: 0.75rem 1.25rem 0.75rem 2.65rem;
  background: var(--bg-dark);
  border: none;
  border-radius: var(--radius-full);
  box-shadow: var(--neu-inset);
  color: var(--text-heading);
  font-size: 0.92rem;
  transition: var(--transition-fast);
  box-sizing: border-box;
}
.search-box-wrapper input:focus {
  outline: none;
  box-shadow: var(--neu-inset), 0 0 0 2px rgba(0, 183, 31, 0.35);
}
.search-box-wrapper input::placeholder {
  color: var(--text-dim);
}

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

/* Neumorphic Filter Buttons Group (Desktop: Natural Unclipped Soft UI Shadows) */
.filter-tabs,
.filter-buttons-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.65rem;
  background: transparent;
  box-shadow: none;
  border: none;
  padding: 0;
  margin: 0;
  width: fit-content;
  max-width: 100%;
  overflow: visible;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.48rem 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.85);
  background: var(--bg-dark);
  box-shadow: var(--neu-flat-sm);
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: var(--transition-fast);
  user-select: none;
}
.filter-btn:hover {
  box-shadow: var(--neu-flat);
  color: var(--text-heading);
  transform: translateY(-1px);
}
.filter-btn:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}
.filter-btn.active {
  background: var(--bg-dark);
  color: var(--primary);
  box-shadow: var(--neu-pressed);
  border: 1px solid rgba(255, 255, 255, 0.4);
  font-weight: 700;
  transform: translateY(0);
}

/* Debossed / Sunken Number Badge ("lún xuống") */
.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
  font-weight: 700;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  border-radius: var(--radius-full);
  background: var(--bg-dark);
  box-shadow: var(--neu-inset);
  color: var(--text-heading);
  line-height: 1;
  transition: var(--transition-fast);
}

.filter-btn.active .filter-count {
  background: var(--bg-dark);
  color: var(--primary);
  box-shadow: var(--neu-inset);
}

/* ====================================================
   FLOATING ACTION BUTTON (FAB) — THÊM THIẾT BỊ MỚI
   Vibrant Coral-Red Neumorphic Button from Reference
   ==================================================== */
.fab-add-device {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 990;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.9rem 1.55rem;
  background: var(--primary-gradient);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.92rem;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: var(--neu-primary-fab);
  transition: var(--transition-normal);
  user-select: none;
}

.fab-add-device:hover {
  transform: translateY(-2px);
  box-shadow: var(--neu-primary-fab-hover);
}

.fab-add-device:active {
  transform: translateY(0);
  box-shadow: var(--neu-pressed);
}

.fab-icon {
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  background: var(--primary-gradient);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.92rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--neu-primary-fab);
  transition: var(--transition-normal);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--neu-primary-fab-hover);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--neu-pressed);
}

/* ====================================================
   DEVICE CARDS GRID (NEUMORPHIC SCULPTED PLATES)
   ==================================================== */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 1.5rem;
}

.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: var(--neu-flat);
  transition: var(--transition-smooth);
  min-height: 265px;
  height: 100%;
  box-sizing: border-box;
}

.card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.device-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--neu-flat-hover);
}

/* Remove leaf watermark completely */
.device-card::after {
  display: none !important;
}

.device-card > * {
  position: relative;
  z-index: 1;
}

/* Highlight animation when opened from notification */
@keyframes highlight-glow {
  0% { box-shadow: 0 0 0 0 rgba(0, 183, 31, 0.8); }
  50% { box-shadow: 0 0 28px 6px rgba(0, 183, 31, 0.45); }
  100% { box-shadow: var(--neu-flat); }
}
.device-card.highlight-pulse {
  animation: highlight-glow 2.5s ease-out;
  border-color: var(--primary) !important;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.card-title-group {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  min-width: 0;
  flex: 1;
}

.device-platform-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}
.device-platform-icon.platform-ios {
  color: var(--ios-color);
}
.device-platform-icon.platform-android {
  color: var(--android-color);
}
.device-platform-icon.platform-other {
  color: var(--text-muted);
}

.device-title {
  font-family: var(--font-rubik) !important;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 0;
  line-height: 1.25;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
}

#borrow-device-name {
  font-family: var(--font-rubik) !important;
}

.tag-pill.tag-os-version,
.meta-os-version {
  font-family: var(--font-rubik) !important;
  letter-spacing: -0.01em;
}

.platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.28rem 0.75rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-dark);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
  border: none;
  margin-left: auto;
}
.platform-badge.ios {
  background: var(--ios-color);
  color: #ffffff;
}
.platform-badge.android {
  background: var(--android-color);
  color: #ffffff;
}
.platform-badge.other {
  background: var(--text-muted);
  color: #ffffff;
}

.card-actions-dropdown {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  position: relative;
  flex-shrink: 0;
}

/* Circular Neumorphic Control Buttons from Reference Image */
.menu-trigger-btn {
  background: var(--bg-dark);
  box-shadow: var(--neu-flat-sm);
  border: 1px solid rgba(255, 255, 255, 0.85);
  color: var(--text-muted);
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: var(--transition-fast);
}
.menu-trigger-btn:hover {
  color: var(--text-heading);
  box-shadow: var(--neu-flat);
  transform: translateY(-1px);
}
.menu-trigger-btn:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}

.device-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
  background: var(--bg-dark);
  box-shadow: var(--neu-flat-sm);
  border: 1px solid rgba(255, 255, 255, 0.85);
  color: var(--text-main);
}
.tag-pill .anticon,
.tag-pill svg {
  font-size: 0.85rem;
  width: 1em !important;
  height: 1em !important;
  max-width: 1em !important;
  max-height: 1em !important;
  flex-shrink: 0;
}

/* Sunken / Debossed Notes Box */
.device-notes {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text-main);
  background: var(--bg-dark);
  box-shadow: var(--neu-inset);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  margin-bottom: 1.15rem;
  border: none;
  word-break: break-word;
}
.device-notes .anticon,
.device-notes svg {
  font-size: 0.95rem;
  width: 1em !important;
  height: 1em !important;
  max-width: 1em !important;
  max-height: 1em !important;
  margin-top: 0.15rem;
  flex-shrink: 0;
}
.device-notes > span:not(.anticon) {
  flex: 1;
}

/* Status Badge inside Card */
.device-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.28rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 700;
  margin-bottom: 0;
  width: fit-content;
  color: #ffffff;
  border: 1.5px solid transparent;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  letter-spacing: 0.02em;
  flex-shrink: 0;
  white-space: nowrap;
}
.device-status-badge .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.85);
  flex-shrink: 0;
}
.device-status-badge.available {
  background: transparent;
  border-color: var(--status-available);
  color: var(--status-available) !important;
  box-shadow: none;
}
.device-status-badge.available .status-dot {
  background: var(--status-available) !important;
  box-shadow: 0 0 4px var(--status-available-glow);
}
.device-status-badge.borrowed {
  background: transparent;
  border-color: var(--status-borrowed);
  color: var(--status-borrowed) !important;
  box-shadow: none;
}
.device-status-badge.borrowed .status-dot {
  background: var(--status-borrowed) !important;
  box-shadow: 0 0 4px var(--status-borrowed-glow);
}
.device-status-badge.overdue {
  background: var(--status-overdue);
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(245, 34, 45, 0.4);
  animation: pulse-badge 2s infinite ease-in-out;
}

@keyframes pulse-badge {
  0% { transform: scale(1); box-shadow: 0 2px 8px rgba(245, 34, 45, 0.4); }
  50% { transform: scale(1.03); box-shadow: 0 2px 14px rgba(245, 34, 45, 0.65); }
  100% { transform: scale(1); box-shadow: 0 2px 8px rgba(245, 34, 45, 0.4); }
}

/* Borrow Info Container (Clean, no background effect, uniform height across cards) */
.borrow-info-box {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0.25rem 0 0;
  margin-bottom: 0.85rem;
  border: none;
  min-height: 4.2rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.borrow-borrower {
  display: block;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.borrower-handle {
  font-weight: 700;
  color: var(--text-heading);
}
.borrow-time {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 0.35rem;
  margin-bottom: 0.28rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.borrow-time .anticon,
.borrow-time svg {
  font-size: 0.95rem;
  width: 1em !important;
  height: 1em !important;
  max-width: 1em !important;
  max-height: 1em !important;
  flex-shrink: 0;
}
.borrow-countdown {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
}
.borrow-countdown .anticon,
.borrow-countdown svg {
  font-size: 0.95rem;
  width: 1em !important;
  height: 1em !important;
  max-width: 1em !important;
  max-height: 1em !important;
  flex-shrink: 0;
}
.borrow-countdown.warning { color: var(--status-borrowed); }
.borrow-countdown.danger { color: var(--status-overdue); font-weight: 700; }
.borrow-countdown.home { color: var(--primary); font-weight: 600; }

/* Card Footer Actions */
.card-footer {
  margin-top: auto;
  display: flex;
  gap: 0.6rem;
  position: relative;
  z-index: 2;
}

/* Action: Mượn thiết bị (Vibrant Gradient CTA from Reference) */
.btn-borrow {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.78rem 1rem;
  background: var(--primary-gradient);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.92rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--neu-primary-fab);
  transition: var(--transition-fast);
}
.btn-borrow .anticon {
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-borrow:hover {
  transform: translateY(-2px);
  box-shadow: var(--neu-primary-fab-hover);
}
.btn-borrow:active {
  transform: translateY(0);
  box-shadow: var(--neu-pressed);
}

.btn-borrow:disabled,
.btn-borrow.disabled {
  background: var(--bg-dark) !important;
  color: var(--text-muted) !important;
  cursor: not-allowed !important;
  pointer-events: auto !important;
  opacity: 0.65 !important;
  box-shadow: var(--neu-inset) !important;
  border: 1px dashed var(--border-subtle) !important;
  transform: none !important;
  filter: grayscale(0.85) !important;
}

.btn-borrow:disabled:hover,
.btn-borrow.disabled:hover {
  transform: none !important;
  box-shadow: var(--neu-inset) !important;
  background: var(--bg-dark) !important;
}

.btn-borrow:disabled:active,
.btn-borrow.disabled:active {
  transform: none !important;
  box-shadow: var(--neu-inset) !important;
}

/* Action: Nhắc nhở (Neumorphic Sculpted Pill) */
.btn-notify {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.75rem;
  background: var(--bg-dark);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.85);
  font-weight: 700;
  font-size: 0.86rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--neu-flat-sm);
  transition: var(--transition-fast);
}
.btn-notify:hover:not(:disabled) {
  color: var(--primary);
  box-shadow: var(--neu-flat);
  transform: translateY(-1px);
}
.btn-notify:active:not(:disabled) {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}
.btn-notify:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

/* Action: Trả máy (Neumorphic Emerald Pill) */
.btn-return {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.75rem;
  background: var(--bg-dark);
  color: var(--status-available);
  border: 1px solid rgba(255, 255, 255, 0.85);
  font-weight: 700;
  font-size: 0.86rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--neu-flat-sm);
  transition: var(--transition-fast);
}
.btn-return .anticon {
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-return:hover {
  box-shadow: var(--neu-flat);
  transform: translateY(-1px);
}
.btn-return:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}

/* Action: Thu hồi máy (Neumorphic Danger/Revoke Pill) */
.btn-revoke {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.75rem;
  background: var(--bg-dark);
  color: var(--status-overdue);
  border: 1px solid rgba(255, 255, 255, 0.85);
  font-weight: 700;
  font-size: 0.86rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--neu-flat-sm);
  transition: var(--transition-fast);
}
.btn-revoke:hover {
  box-shadow: var(--neu-flat);
  transform: translateY(-1px);
  color: #ff4d4f;
}
.btn-revoke:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}

/* ====================================================
   EMPTY & LOADING STATES
   ==================================================== */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4.5rem 1.5rem;
  background: var(--bg-card);
  box-shadow: var(--neu-inset);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-xl);
}
.empty-icon {
  font-size: 3.2rem;
  margin-bottom: 1rem;
  color: var(--primary);
  opacity: 0.85;
}
.empty-title {
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: 0.45rem;
  color: var(--text-heading);
}
.empty-desc {
  color: var(--text-muted);
  max-width: 440px;
  margin: 0 auto 1.5rem;
  font-size: 0.92rem;
}

/* ====================================================
   MODAL DIALOGS (NEUMORPHIC SCULPTED SHEET)
   ==================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 32, 44, 0.48);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 530px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--neu-dialog);
  transform: scale(0.95) translateY(14px);
  transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1);
}
.modal-backdrop.active .modal-dialog {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 1.7rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.85);
}
.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
}

/* Circular Close Button */
.btn-close-modal {
  background: var(--bg-dark);
  box-shadow: var(--neu-flat-sm);
  border: 1px solid rgba(255, 255, 255, 0.85);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--transition-fast);
}
.btn-close-modal:hover {
  box-shadow: var(--neu-flat);
  color: var(--text-heading);
  transform: translateY(-1px);
}
.btn-close-modal:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}

.modal-body {
  padding: 1.6rem 1.7rem;
}

.modal-footer {
  padding: 1.15rem 1.7rem;
  border-top: 1px solid rgba(255, 255, 255, 0.85);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--bg-dark);
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
}

/* Sticky Modal Footer for User Identity Modal */
#modal-user-identity .modal-dialog {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

#modal-user-identity .modal-header {
  flex-shrink: 0;
}

#modal-user-identity #form-user-identity {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#modal-user-identity .modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#modal-user-identity .modal-footer {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: var(--bg-surface);
  border-top: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 -4px 14px rgba(197, 202, 214, 0.45);
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
}

/* Forms in Modals (Sunken / Debossed Fields from Reference) */
.form-group {
  margin-bottom: 1.25rem;
}
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 0.45rem;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-dark);
  border: none;
  box-shadow: var(--neu-inset);
  border-radius: var(--radius-md);
  color: var(--text-heading);
  font-size: 0.92rem;
  transition: var(--transition-fast);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  box-shadow: var(--neu-inset), 0 0 0 2px rgba(0, 183, 31, 0.35);
}

/* Duration Radio Cards */
.radio-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.radio-card {
  position: relative;
  display: block;
  cursor: pointer;
}
.radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
}
.radio-card-content {
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-md);
  padding: 1rem 0.85rem;
  background: var(--bg-dark);
  box-shadow: var(--neu-flat-sm);
  transition: var(--transition-fast);
  text-align: center;
}
.radio-card:hover .radio-card-content {
  box-shadow: var(--neu-flat);
  transform: translateY(-1px);
}
.radio-card input[type="radio"]:checked + .radio-card-content {
  border-color: var(--primary);
  background: var(--bg-dark);
  box-shadow: var(--neu-inset);
}
.radio-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 0.2rem;
}
.radio-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
}
.radio-card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.radio-card.disabled .radio-card-content {
  box-shadow: none;
  background: var(--bg-main);
  border-color: rgba(0, 0, 0, 0.05);
}

/* Secondary & Danger Buttons in Modals */
.btn-secondary {
  padding: 0.75rem 1.3rem;
  background: var(--bg-dark);
  border: 1px solid rgba(255, 255, 255, 0.85);
  color: var(--text-heading);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--neu-flat-sm);
  transition: var(--transition-fast);
}
.btn-secondary:hover {
  box-shadow: var(--neu-flat);
  transform: translateY(-1px);
}
.btn-secondary:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}

.btn-danger {
  padding: 0.75rem 1.3rem;
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  border: none;
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--neu-flat-sm), 0 4px 12px rgba(239, 68, 68, 0.35);
  transition: var(--transition-fast);
}
.btn-danger:hover {
  box-shadow: var(--neu-flat), 0 6px 16px rgba(239, 68, 68, 0.45);
  transform: translateY(-1px);
}
.btn-danger:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}

/* ====================================================
   TOAST NOTIFICATION SYSTEM (NEUMORPHIC FLOATING PILL)
   ==================================================== */
.toast-container {
  position: fixed;
  bottom: 5.5rem;
  right: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  z-index: 2000;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 0.9rem 1.3rem;
  background: var(--bg-dark);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-md);
  box-shadow: var(--neu-flat-lg);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--text-heading);
  font-size: 0.88rem;
  animation: slide-toast 0.3s cubic-bezier(0.2, 0, 0, 1);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.success { border-left: 5px solid var(--status-available); }
.toast.info { border-left: 5px solid var(--primary); }
.toast.warning { border-left: 5px solid var(--status-borrowed); }
.toast.error { border-left: 5px solid var(--status-overdue); }

@keyframes slide-toast {
  from { transform: translateX(100%) scale(0.9); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}

/* ====================================================
   TOP FLOATING PUSH NOTIFICATION BANNER (IN-APP HEADS-UP)
   ==================================================== */
.top-floating-banner-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: min(94vw, 480px);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.top-floating-banner {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-left: 5px solid var(--primary);
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.08);
  padding: 1rem 1.15rem;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  animation: banner-slide-down 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.3s ease, transform 0.3s ease;
  position: relative;
  overflow: hidden;
}

.top-floating-banner.nudge-alert {
  border-left-color: #D97706; /* Amber gold for return nudge */
}

.top-floating-banner.overdue-alert {
  border-left-color: var(--status-overdue);
}

.banner-bell-wrapper {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.15), rgba(245, 158, 11, 0.25));
  color: #D97706;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.2);
  animation: bell-bounce 1.5s infinite;
}

.banner-content {
  flex: 1;
  min-width: 0;
}

.banner-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-heading);
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.banner-time {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.banner-body {
  font-size: 0.84rem;
  color: var(--text-body);
  line-height: 1.42;
  margin-bottom: 0.6rem;
  word-break: break-word;
}

.banner-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.banner-btn-view {
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: 8px;
  padding: 0.35rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.banner-btn-view:active {
  transform: scale(0.96);
}

.banner-btn-dismiss {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}

.banner-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.banner-close-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

@keyframes banner-slide-down {
  from {
    transform: translateY(-120%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes bell-bounce {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(14deg); }
  30% { transform: rotate(-14deg); }
  45% { transform: rotate(10deg); }
  60% { transform: rotate(-6deg); }
  75% { transform: rotate(0deg); }
}

/* ====================================================
   DIAGNOSTIC PANEL & TROUBLESHOOTING GUIDE
   ==================================================== */
.diagnostic-panel {
  background: var(--bg-dark);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-lg);
  box-shadow: var(--neu-flat-sm);
  padding: 1.3rem;
  margin-top: 1.35rem;
}

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

.diagnostic-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.diagnostic-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}

.diagnostic-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.5rem;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 0.86rem;
}
.diagnostic-item:last-child {
  border-bottom: none;
}

.diagnostic-label {
  color: var(--text-heading);
  font-weight: 600;
}

.diagnostic-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
  background: var(--bg-dark);
  box-shadow: var(--neu-flat-sm);
  border: 1px solid rgba(255, 255, 255, 0.85);
}
.diagnostic-badge.ok {
  color: #047857;
  background: var(--status-available-bg);
  border-color: #A7F3D0;
}
.diagnostic-badge.warn {
  color: #B45309;
  background: var(--status-borrowed-bg);
  border-color: #FDE68A;
}
.diagnostic-badge.error {
  color: #B91C1C;
  background: var(--status-overdue-bg);
  border-color: #FECACA;
}

.diagnostic-msg-box {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  line-height: 1.5;
  margin-bottom: 0.95rem;
  box-shadow: none;
  border: none;
}
.diagnostic-msg-box.ok {
  color: #065F46;
  background: #D1FAE5;
  border: 1px solid #A7F3D0;
}
.diagnostic-msg-box.ok small {
  color: #047857 !important;
  font-weight: 500;
  font-size: 0.82rem;
  display: inline-block;
  margin-top: 0.25rem;
}
.diagnostic-msg-box.warn {
  color: #92400E;
  background: #FEF3C7;
  border: 1px solid #FDE68A;
}
.diagnostic-msg-box.warn small {
  color: #78350F !important;
  font-weight: 500;
  font-size: 0.82rem;
  display: inline-block;
  margin-top: 0.25rem;
}
.diagnostic-msg-box.error {
  color: #991B1B;
  background: #FEE2E2;
  border: 1px solid #FECACA;
}
.diagnostic-msg-box.error small {
  color: #7F1D1D !important;
  font-weight: 500;
  font-size: 0.82rem;
  display: inline-block;
  margin-top: 0.25rem;
}

.diagnostic-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Admin Mode Setting Box & Neumorphic Toggle Switch */
.admin-setting-box {
  margin-top: 1.15rem;
  background: var(--bg-dark);
  box-shadow: var(--neu-inset);
  border-radius: var(--radius-md);
  padding: 0.95rem 1.05rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #CBD5E1;
  border-radius: 34px;
  transition: var(--transition-fast);
  box-shadow: var(--neu-inset);
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #FFFFFF;
  border-radius: 50%;
  transition: var(--transition-fast);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.diagnostic-btn {
  flex: 1;
  min-width: 140px;
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.85);
  background: var(--bg-dark);
  box-shadow: var(--neu-flat-sm);
  color: var(--text-heading);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: var(--transition-fast);
}
.diagnostic-btn:hover {
  box-shadow: var(--neu-flat);
  transform: translateY(-1px);
}
.diagnostic-btn:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}
.diagnostic-btn.primary {
  background: var(--primary-gradient);
  color: #FFFFFF;
  border: none;
  box-shadow: var(--neu-primary-fab);
}
.diagnostic-btn.primary:hover {
  box-shadow: var(--neu-primary-fab-hover);
}
.diagnostic-btn.danger {
  color: var(--status-overdue);
}

/* Guide Modal Steps */
.guide-step-card {
  background: var(--bg-dark);
  box-shadow: var(--neu-flat-sm);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  margin-bottom: 0.95rem;
}
.guide-step-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.guide-step-desc {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.55;
}
.guide-step-desc ol {
  padding-left: 1.25rem;
  margin-top: 0.4rem;
}
.guide-step-desc li {
  margin-bottom: 0.35rem;
}

/* ====================================================
   RESPONSIVE DESIGN (MOBILE & TABLET)
   ==================================================== */
@media (max-width: 768px) {
  .app-container {
    padding: 0.85rem 0.75rem 3rem;
  }

  /* Header scaling */
  .app-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.25rem 0;
    gap: 0.65rem;
    margin-bottom: 1.35rem;
    background: transparent;
    border: none;
    box-shadow: none;
    width: 100%;
  }

  .brand-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    min-width: 0;
    flex: 1;
  }

  .brand-logo-glow {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    flex-shrink: 0;
    margin-top: 1px;
  }

  .brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
  }

  .brand-title {
    font-size: 1.25rem;
    line-height: 1.2;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-subtitle {
    font-size: 0.82rem;
    line-height: 1.35;
    margin-top: 0.2rem;
    color: var(--text-muted);
    padding-left: 0;
  }

  .header-controls {
    width: auto;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.55rem;
    flex-shrink: 0;
    margin-left: auto;
  }

  .header-controls .user-identity-btn {
    height: 34px;
    padding: 0 0.8rem;
    box-sizing: border-box;
    font-size: 0.84rem;
    font-weight: 700;
    margin-left: 0;
    gap: 0.5rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .header-controls .user-identity-btn span:last-child {
    max-width: 105px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
  }

  .header-controls .notif-permission-btn,
  .header-controls .theme-toggle-btn {
    width: 34px;
    height: 34px;
    box-sizing: border-box;
    font-size: 1.05rem;
    flex-shrink: 0;
  }


  /* Toolbar & Filter Bar */
  .toolbar-section {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
  }

  .search-and-filters {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  /* Filter Buttons on mobile: Single line without wrapping, smooth horizontal scrolling with shadow padding */
  .filter-tabs,
  .filter-buttons-group {
    width: calc(100% + 12px);
    max-width: calc(100% + 12px);
    box-sizing: border-box;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem;
    padding: 10px 8px 12px 6px;
    margin: -10px -6px -8px -6px;
    background: transparent;
    box-shadow: none;
    border: none;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .filter-tabs::-webkit-scrollbar,
  .filter-buttons-group::-webkit-scrollbar {
    display: none;
  }

  .filter-btn {
    flex: 0 0 auto;
    flex-shrink: 0;
    padding: 0.44rem 0.88rem;
    font-size: 0.82rem;
    gap: 0.4rem;
    white-space: nowrap;
  }

  /* Search Box on mobile: Below filter buttons, width matches filter buttons (100%) */
  .search-box-wrapper {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin-left: 0;
    box-sizing: border-box;
  }

  .search-box-wrapper input {
    width: 100%;
    font-size: 0.88rem;
    padding: 0.68rem 1rem 0.68rem 2.45rem;
    box-sizing: border-box;
  }

  /* Floating Action Button on mobile: circular icon-only button */
  .fab-add-device {
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    right: calc(1.25rem + env(safe-area-inset-right, 0px));
    box-shadow: var(--neu-primary-fab);
  }

  .fab-add-device .fab-text {
    display: none;
  }

  .fab-add-device .fab-icon {
    font-size: 1.45rem;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ====================================================
     COMPACT MOBILE DEVICE CARDS (LOWER HEIGHT, HIGH DENSITY)
     ==================================================== */
  .device-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .device-card {
    padding: 0.8rem 0.95rem;
    border-radius: var(--radius-md);
    min-height: auto;
    height: auto;
    gap: 0;
    box-sizing: border-box;
  }

  .card-body {
    flex: none;
    min-height: auto;
  }

  /* Hide separate platform text badge on mobile, icon is directly beside device name */
  .card-header .platform-badge {
    display: none !important;
  }

  .card-header {
    margin-bottom: 0.35rem;
    gap: 0.45rem;
    align-items: flex-start;
  }

  .card-title-group {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    min-width: 0;
    flex: 1;
  }

  .device-platform-icon {
    font-size: 1.15rem;
    margin-top: 1px;
    flex-shrink: 0;
  }

  .device-title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 0;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
  }

  .card-actions-dropdown {
    gap: 0.35rem;
  }

  .menu-trigger-btn {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  /* Compact meta row with status badge and tags */
  .device-meta-row {
    gap: 0.35rem;
    margin-bottom: 0.35rem;
  }

  .device-status-badge {
    padding: 0.18rem 0.55rem;
    font-size: 0.72rem;
    margin-bottom: 0;
    gap: 0.3rem;
  }

  .device-status-badge .status-dot {
    width: 6px;
    height: 6px;
  }

  .tag-pill {
    padding: 0.18rem 0.5rem;
    font-size: 0.7rem;
    gap: 0.25rem;
  }

  /* Hide device notes on mobile view */
  .device-notes {
    display: none !important;
  }

  /* Compact borrow info box */
  .borrow-info-box {
    background: transparent;
    box-shadow: none;
    padding: 0.2rem 0 0;
    margin-bottom: 0.45rem;
    border-radius: 0;
    min-height: auto;
  }

  .borrow-info-box.available-box {
    display: none !important;
  }

  .borrow-borrower {
    font-size: 0.78rem;
    margin-bottom: 0.2rem;
  }

  .borrow-time {
    font-size: 0.74rem;
    padding-top: 0.25rem;
    margin-bottom: 0.18rem;
    gap: 0.25rem;
  }

  .borrow-countdown {
    font-size: 0.74rem;
    gap: 0.25rem;
  }

  /* Compact card footer action button */
  .card-footer {
    margin-top: 0.35rem;
  }

  .btn-borrow,
  .btn-return,
  .btn-notify,
  .btn-revoke {
    padding: 0.46rem 0.85rem;
    font-size: 0.82rem;
    height: 36px;
    border-radius: var(--radius-sm);
    justify-content: center;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 5.25rem;
  }

  /* Responsive Sticky Modal Footer for User Identity Modal */
  #modal-user-identity .modal-dialog {
    max-height: 92vh;
    border-radius: var(--radius-lg);
  }

  #modal-user-identity .modal-body {
    padding: 1.25rem 1.35rem;
  }

  #modal-user-identity .modal-footer {
    padding: 0.95rem 1.35rem;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
  }

  /* Extra compact header adjustments for small screens (≤ 480px) */
  @media (max-width: 480px) {
    .brand-title {
      font-size: 1.15rem;
    }
    .brand-logo-glow {
      width: 35px;
      height: 35px;
      border-radius: 10px;
    }
    .header-top-row {
      gap: 0.45rem;
    }
    .header-controls {
      gap: 0.4rem;
    }
    .header-controls .user-identity-btn {
      height: 32px;
      padding: 0 0.65rem;
      box-sizing: border-box;
      font-size: 0.8rem;
      gap: 0.4rem;
    }
    .header-controls .user-identity-btn span:last-child {
      max-width: 82px;
    }
    .header-controls .notif-permission-btn {
      width: 32px;
      height: 32px;
      box-sizing: border-box;
      font-size: 0.95rem;
    }
  }
}

/* ====================================================
   USERNAME AVAILABILITY & EXISTING USER FEEDBACK
   ==================================================== */
.username-feedback-box {
  margin-top: 0.45rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  line-height: 1.45;
  transition: var(--transition-fast);
}

.username-feedback-box.warning {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #B91C1C;
}

.username-feedback-box.warning code {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.28);
  border-radius: 4px;
  padding: 1px 6px;
  color: #991B1B;
  font-weight: 700;
}

.username-feedback-box.available {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #047857;
}

.btn-login-existing-user {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%) !important;
  color: #FFFFFF !important;
  border: 1px solid rgba(255, 255, 255, 0.55) !important;
  border-radius: 9999px !important;
  padding: 0.45rem 1.05rem !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.25px !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.45rem !important;
  box-shadow: 
    0 4px 14px rgba(5, 150, 105, 0.42),
    0 2px 5px rgba(0, 0, 0, 0.14),
    inset 0 1px 2px rgba(255, 255, 255, 0.45) !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25) !important;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.btn-login-existing-user:hover {
  background: linear-gradient(135deg, #34D399 0%, #047857 100%) !important;
  color: #FFFFFF !important;
  transform: translateY(-2px) scale(1.03) !important;
  box-shadow: 
    0 7px 20px rgba(5, 150, 105, 0.55),
    0 3px 8px rgba(0, 0, 0, 0.18),
    inset 0 1px 2px rgba(255, 255, 255, 0.65) !important;
}

.btn-login-existing-user:active {
  transform: translateY(1px) scale(0.98) !important;
  box-shadow: 
    0 2px 6px rgba(5, 150, 105, 0.35),
    inset 0 2px 4px rgba(0, 0, 0, 0.25) !important;
}

/* ====================================================
   DARK MODE REFINEMENTS & COMPONENT HARMONIZATION
   ==================================================== */
[data-theme="dark"] .brand-title {
  color: var(--text-brand) !important;
}

[data-theme="dark"] [class*="btn"],
[data-theme="dark"] .brand-logo-glow,
[data-theme="dark"] .user-identity-btn,
[data-theme="dark"] .notif-permission-btn,
[data-theme="dark"] .theme-toggle-btn,
[data-theme="dark"] .filter-btn,
[data-theme="dark"] .menu-trigger-btn,
[data-theme="dark"] .tag-pill,
[data-theme="dark"] .device-card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .banner-notice,
[data-theme="dark"] .toast,
[data-theme="dark"] .modal-dialog,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .btn-close-modal,
[data-theme="dark"] .radio-card-content,
[data-theme="dark"] .empty-state,
[data-theme="dark"] .admin-setting-box {
  border-color: var(--border-subtle) !important;
}

[data-theme="dark"] .modal-backdrop {
  background: rgba(10, 12, 16, 0.72);
}

[data-theme="dark"] .top-floating-banner {
  background: rgba(26, 29, 35, 0.96);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
}

[data-theme="dark"] .toggle-slider {
  background-color: #2D313A;
}

[data-theme="dark"] .diagnostic-msg-box.ok {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.35);
  color: #6EE7B7;
}
[data-theme="dark"] .diagnostic-msg-box.ok small {
  color: #A7F3D0 !important;
}
[data-theme="dark"] .diagnostic-msg-box.warn {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.35);
  color: #FCD34D;
}
[data-theme="dark"] .diagnostic-msg-box.warn small {
  color: #FDE68A !important;
}
[data-theme="dark"] .diagnostic-msg-box.error {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.35);
  color: #FCA5A5;
}
[data-theme="dark"] .diagnostic-msg-box.error small {
  color: #FECACA !important;
}

/* ====================================================
   NEUMORPHIC THEME TOGGLE (LAMP SWITCH) BUTTON
   ==================================================== */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--bg-dark);
  box-shadow: var(--neu-flat-sm);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: var(--transition-fast);
  outline: none;
  user-select: none;
}
.theme-toggle-btn:hover {
  color: var(--text-heading);
  box-shadow: var(--neu-flat);
  transform: translateY(-1px);
}
.theme-toggle-btn:active {
  box-shadow: var(--neu-pressed);
  transform: translateY(0);
}

/* Light Mode active state on button (Warm Glowing Bulb) */
:root:not([data-theme="dark"]) .theme-toggle-btn {
  color: #D97706;
}
:root:not([data-theme="dark"]) .theme-toggle-btn:hover {
  color: #B45309;
  box-shadow: var(--neu-flat), 0 0 14px rgba(245, 158, 11, 0.4);
}

/* Dark Mode active state on button (Luminous Moon & Stars) */
[data-theme="dark"] .theme-toggle-btn {
  color: #38BDF8;
}
[data-theme="dark"] .theme-toggle-btn:hover {
  color: #7DD3FC;
  box-shadow: var(--neu-flat), 0 0 16px rgba(56, 189, 248, 0.45);
}

.theme-toggle-btn svg,
.theme-toggle-btn .lamp-icon {
  width: 1em !important;
  height: 1em !important;
  max-width: 1em !important;
  max-height: 1em !important;
  display: inline-block;
  vertical-align: middle;
}

/* Switch click tactile bounce animation */
.theme-toggle-btn.btn-lamp-pull {
  animation: switch-pull-click 0.38s cubic-bezier(0.2, 0.8, 0.4, 1.4);
}

@keyframes switch-pull-click {
  0% { transform: scale(1); }
  35% { transform: scale(0.85) translateY(2px); }
  70% { transform: scale(1.1) translateY(-1px); }
  100% { transform: scale(1) translateY(0); }
}

/* ====================================================
   FULL-SCREEN "MỞ ĐÈN / TẮT ĐÈN" (LIGHT SWITCH) EFFECT
   ==================================================== */
.lamp-effect-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99999;
  opacity: 0;
  visibility: hidden;
}

/* TẮT ĐÈN (Turning off light): Power cutoff & darkness falling */
.lamp-effect-overlay.turning-off {
  visibility: visible;
  animation: lamp-turn-off-fx 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes lamp-turn-off-fx {
  0% {
    opacity: 0;
    background: radial-gradient(circle at var(--switch-x, 80%) var(--switch-y, 20px), rgba(255, 230, 160, 0.4) 0%, transparent 60%);
    filter: brightness(1);
  }
  12% {
    /* Filament spark right before blackout */
    opacity: 0.75;
    background: radial-gradient(circle at var(--switch-x, 80%) var(--switch-y, 20px), rgba(255, 200, 100, 0.6) 0%, rgba(20, 20, 24, 0.4) 70%);
    filter: brightness(1.25);
  }
  28% {
    /* Sudden power dip */
    opacity: 0.92;
    background: radial-gradient(circle at var(--switch-x, 80%) var(--switch-y, 20px), rgba(15, 17, 21, 0.85) 0%, rgba(10, 12, 15, 0.95) 100%);
    filter: brightness(0.4);
  }
  60% {
    /* Darkness settling into night */
    opacity: 0.45;
    background: #111316;
    filter: brightness(0.85);
  }
  100% {
    opacity: 0;
    visibility: hidden;
    filter: brightness(1);
  }
}

/* MỞ ĐÈN (Turning on light): Fluorescent/Tungsten filament ignition flicker & daylight flare */
.lamp-effect-overlay.turning-on {
  visibility: visible;
  animation: lamp-turn-on-fx 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes lamp-turn-on-fx {
  0% {
    opacity: 0;
    filter: brightness(0.8);
  }
  10% {
    /* First electric spark! */
    opacity: 0.85;
    background: radial-gradient(circle at var(--switch-x, 80%) var(--switch-y, 20px), rgba(255, 255, 240, 0.9) 0%, rgba(255, 220, 120, 0.4) 40%, transparent 80%);
    filter: brightness(1.5);
  }
  22% {
    /* Micro dip / hesitation */
    opacity: 0.35;
    background: radial-gradient(circle at var(--switch-x, 80%) var(--switch-y, 20px), rgba(255, 200, 80, 0.25) 0%, transparent 60%);
    filter: brightness(0.9);
  }
  38% {
    /* Second powerful ignition burst catching full glow */
    opacity: 0.95;
    background: radial-gradient(circle at var(--switch-x, 80%) var(--switch-y, 20px), rgba(255, 255, 255, 0.95) 0%, rgba(254, 243, 199, 0.65) 50%, rgba(235, 236, 240, 0.35) 100%);
    filter: brightness(1.4);
  }
  68% {
    /* Light wave expanding smoothly across the room */
    opacity: 0.45;
    background: radial-gradient(circle at var(--switch-x, 80%) var(--switch-y, 20px), rgba(255, 255, 255, 0.6) 0%, rgba(235, 236, 240, 0.4) 100%);
    filter: brightness(1.1);
  }
  100% {
    opacity: 0;
    visibility: hidden;
    filter: brightness(1);
  }
}

/* Smooth color transitions when theme changes */
body.theme-transitioning,
body.theme-transitioning * {
  transition: background-color 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
              border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
              color 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
              box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* View Transition API Circular Reveal (Chrome 111+, Safari 18+) */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) {
  z-index: 1;
}
::view-transition-new(root) {
  z-index: 2;
}

