/* ============================================================
   LucixWar TempMail — Premium Redesign
   ============================================================ */
:root {
  --bg: #080810;
  --bg2: #0e0e1a;
  --sidebar-w: 240px;
  --glass: rgba(255, 255, 255, 0.04);
  --glass-hover: rgba(255, 255, 255, 0.07);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-hover: rgba(255, 255, 255, 0.16);
  --text: #eeeef5;
  --text2: #7777a0;
  --text3: #44445a;
  --p: #8b5cf6;
  --p-light: #a78bfa;
  --c: #06b6d4;
  --c-light: #22d3ee;
  --g: #10b981;
  --r: #ef4444;
  --grad: linear-gradient(135deg, #8b5cf6, #06b6d4);
  --grad-hover: linear-gradient(135deg, #a78bfa, #22d3ee);
  --grad-glow: linear-gradient(135deg, rgba(139, 92, 246, .25), rgba(6, 182, 212, .25));
  --shadow: 0 4px 24px rgba(0, 0, 0, .5);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, .6);
  --r4: 4px;
  --r8: 8px;
  --r12: 12px;
  --r16: 16px;
  --r20: 20px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased
}

/* BG blobs */
.bg-blobs {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .3
}

.blob-1 {
  width: 500px;
  height: 500px;
  background: rgba(139, 92, 246, .3);
  top: -150px;
  left: -100px;
  animation: bf 18s ease-in-out infinite
}

.blob-2 {
  width: 400px;
  height: 400px;
  background: rgba(6, 182, 212, .2);
  bottom: -100px;
  right: -80px;
  animation: bf 22s ease-in-out infinite -8s
}

.blob-3 {
  width: 300px;
  height: 300px;
  background: rgba(167, 139, 250, .15);
  top: 45%;
  left: 55%;
  animation: bf 26s ease-in-out infinite -16s
}

@keyframes bf {

  0%,
  100% {
    transform: translate(0, 0) scale(1)
  }

  33% {
    transform: translate(40px, -60px) scale(1.1)
  }

  66% {
    transform: translate(-30px, 30px) scale(.95)
  }
}

/* ===== App layout ===== */
#app {
  position: relative;
  z-index: 1;
  min-height: 100vh
}

.view {
  display: none;
  min-height: 100vh;
  min-height: 100dvh
}

.view.active {
  display: flex;
  flex-direction: column
}

/* glass */
.glass-card {
  background: var(--glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r16);
  transition: border-color .2s var(--ease)
}

.glass-card:hover {
  border-color: var(--glass-border-hover)
}

/* gradient text */
.gradient-text {
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: none;
  border-radius: var(--r8);
  font-family: inherit;
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s var(--ease);
  white-space: nowrap;
  text-decoration: none
}

.btn-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0
}

.btn-lg {
  padding: 13px 20px;
  font-size: .95rem;
  border-radius: var(--r12)
}

.btn-sm {
  padding: 6px 12px;
  font-size: .78rem
}

.btn-full {
  width: 100%;
  justify-content: center
}

.btn-icon-only {
  padding: 7px
}

.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 16px rgba(139, 92, 246, .3)
}

.btn-primary:hover {
  background: var(--grad-hover);
  box-shadow: 0 6px 24px rgba(139, 92, 246, .4);
  transform: translateY(-1px)
}

.btn-primary:active {
  transform: none
}

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--glass-border)
}

.btn-ghost:hover {
  background: var(--glass-hover);
  color: var(--text);
  border-color: var(--glass-border-hover)
}

.btn-accent {
  background: rgba(6, 182, 212, .12);
  color: var(--c);
  border: 1px solid rgba(6, 182, 212, .25)
}

.btn-accent:hover {
  background: rgba(6, 182, 212, .22);
  border-color: rgba(6, 182, 212, .45)
}

.btn-danger {
  background: rgba(239, 68, 68, .1);
  color: var(--r);
  border: 1px solid rgba(239, 68, 68, .22)
}

.btn-danger:hover {
  background: rgba(239, 68, 68, .2);
  border-color: rgba(239, 68, 68, .4)
}

/* ===== Auth ===== */
#login-view,
#signup-view {
  background: radial-gradient(ellipse at 30% 20%, rgba(139, 92, 246, .08) 0%, transparent 60%), radial-gradient(ellipse at 70% 80%, rgba(6, 182, 212, .06) 0%, transparent 60%), var(--bg)
}

.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  gap: 24px
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  animation: fadeUp .5s ease-out
}

.auth-logo-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r12);
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 30px rgba(139, 92, 246, .3);
  flex-shrink: 0
}

.auth-logo-icon svg {
  width: 26px;
  height: 26px
}

.auth-brand {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.1
}

.auth-tagline {
  font-size: .85rem;
  color: var(--text2);
  margin-top: 3px
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 32px;
  animation: fadeUp .5s ease-out .1s both
}

.auth-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 4px
}

.auth-card-sub {
  font-size: .85rem;
  color: var(--text2);
  margin-bottom: 24px
}

.form-group {
  margin-bottom: 14px
}

.form-group label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .4px
}

.form-group label small {
  font-size: .72rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text3);
  font-weight: 400
}

.form-group input {
  width: 100%;
  padding: 10px 13px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--glass-border);
  border-radius: var(--r8);
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  transition: all .2s var(--ease);
  outline: none
}

.form-group input:focus {
  border-color: var(--p);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, .15)
}

.form-group input::placeholder {
  color: var(--text3)
}

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

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: .85rem;
  color: var(--text2)
}

.auth-switch a {
  color: var(--c);
  font-weight: 600;
  text-decoration: none
}

.auth-switch a:hover {
  text-decoration: underline
}

/* alerts */
.alert {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--r8);
  font-size: .82rem;
  text-align: center
}

.alert-error {
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(239, 68, 68, .25);
  color: var(--r)
}

.alert-success {
  background: rgba(16, 185, 129, .1);
  border: 1px solid rgba(16, 185, 129, .25);
  color: var(--g)
}

/* ===== Dashboard Layout ===== */
#dashboard-view {
  flex-direction: row;
  min-height: 100vh
}

/* sidebar */
.sidebar {
  position: fixed;
  left: 12px;
  top: 12px;
  bottom: 12px;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  z-index: 20;
  border-radius: var(--r20);
  overflow: hidden
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--glass-border)
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r8);
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0
}

.sidebar-brand-icon svg {
  width: 18px;
  height: 18px
}

.sidebar-brand-text {
  font-size: .8rem;
  color: var(--text2);
  line-height: 1.3
}

.sidebar-brand-text strong {
  color: var(--text);
  font-size: .9rem;
  font-weight: 700;
  display: block
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border)
}

.sidebar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0
}

.sidebar-user-info {
  min-width: 0
}

.sidebar-user-name {
  font-weight: 600;
  font-size: .85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  flex: 1;
  overflow-y: auto
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border: none;
  border-radius: var(--r8);
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: .83rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s var(--ease);
  width: 100%;
  text-align: left;
  position: relative
}

.nav-item:hover {
  background: var(--glass-hover);
  color: var(--text)
}

.nav-item.active {
  background: rgba(139, 92, 246, .15);
  color: var(--p-light);
  font-weight: 600
}

.nav-item.active svg {
  color: var(--p)
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .7
}

.nav-item.active svg {
  opacity: 1
}

.nav-item-danger:hover {
  background: rgba(239, 68, 68, .12);
  color: var(--r)
}

.nav-badge {
  margin-left: auto;
  background: var(--grad);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 100px;
  min-width: 18px;
  text-align: center
}

.sidebar-footer {
  padding: 8px 8px 12px
}

/* Mobile topbar (hidden on desktop) */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  margin: 8px;
  position: sticky;
  top: 8px;
  z-index: 20;
  border-radius: var(--r12);
  flex-shrink: 0
}

.mobile-brand {
  font-size: .95rem;
  font-weight: 700
}

.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 19;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px)
}

/* main content */
.main-content {
  margin-left: calc(var(--sidebar-w) + 24px);
  flex: 1;
  padding: 20px 20px 20px 0;
  min-height: 100vh;
  min-width: 0;
  overflow-x: hidden
}

.section {
  animation: fadeUp .3s ease-out
}

/* page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap
}

.page-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -.3px
}

.page-subtitle {
  font-size: .82rem;
  color: var(--text2);
  margin-top: 3px
}

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--r12);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  transition: all .2s var(--ease);
  animation: fadeUp .4s ease-out backwards
}

.stat-card:hover {
  border-color: var(--glass-border-hover);
  transform: translateY(-2px)
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r8);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0
}

.stat-icon svg {
  width: 20px;
  height: 20px
}

.stat-icon-purple {
  background: rgba(139, 92, 246, .15);
  color: var(--p-light)
}

.stat-icon-cyan {
  background: rgba(6, 182, 212, .15);
  color: var(--c-light)
}

.stat-icon-green {
  background: rgba(16, 185, 129, .15);
  color: var(--g)
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1
}

.stat-label {
  font-size: .75rem;
  color: var(--text2);
  margin-top: 3px;
  font-weight: 500
}

/* ===== Email List (row style) ===== */
.emails-list {
  display: flex;
  flex-direction: column;
  gap: 8px
}

.email-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--r12);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: all .2s var(--ease);
  animation: fadeUp .35s ease-out backwards
}

.email-row:hover {
  background: var(--glass-hover);
  border-color: var(--glass-border-hover);
  transform: translateX(3px)
}

.email-row-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--r8);
  background: var(--grad-glow);
  border: 1px solid rgba(139, 92, 246, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  color: var(--p-light);
  flex-shrink: 0;
  text-transform: uppercase
}

.email-row-info {
  flex: 1;
  min-width: 0
}

.email-row-addr {
  font-weight: 600;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px
}

.email-row-meta {
  font-size: .73rem;
  color: var(--text2)
}

.email-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0
}

.email-owner-chip {
  padding: 3px 8px;
  border-radius: 100px;
  background: rgba(6, 182, 212, .1);
  border: 1px solid rgba(6, 182, 212, .2);
  color: var(--c);
  font-size: .7rem;
  font-weight: 600
}

.unread-chip {
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--grad);
  color: #fff;
  font-size: .7rem;
  font-weight: 700
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r8);
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s var(--ease);
  flex-shrink: 0
}

.icon-btn svg {
  width: 13px;
  height: 13px
}

.icon-btn.copy:hover {
  background: rgba(16, 185, 129, .15);
  border-color: rgba(16, 185, 129, .4);
  color: var(--g)
}

.icon-btn.del:hover {
  background: rgba(239, 68, 68, .15);
  border-color: rgba(239, 68, 68, .4);
  color: var(--r)
}

/* ===== Users Grid ===== */
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px
}

.user-card {
  padding: 16px 18px;
  border-radius: var(--r12);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  transition: all .2s var(--ease);
  animation: fadeUp .35s ease-out backwards
}

.user-card:hover {
  border-color: var(--glass-border-hover)
}

.user-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px
}

.user-card-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .9rem;
  flex-shrink: 0;
  text-transform: uppercase
}

.user-card-name {
  font-weight: 700;
  font-size: .9rem;
  margin-bottom: 3px
}

.user-card-username {
  font-size: .75rem;
  color: var(--text2)
}

.user-card-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 12px
}

.user-stat {
  text-align: center;
  flex: 1;
  padding: 8px;
  background: rgba(255, 255, 255, .03);
  border-radius: var(--r8);
  border: 1px solid var(--glass-border)
}

.user-stat-val {
  font-weight: 700;
  font-size: .95rem
}

.user-stat-lbl {
  font-size: .68rem;
  color: var(--text2);
  margin-top: 2px
}

.user-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between
}

.user-whatsapp {
  font-size: .75rem;
  color: var(--text2)
}

/* Role badges */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px
}

.role-admin {
  background: rgba(239, 68, 68, .15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, .3)
}

.role-manager {
  background: rgba(6, 182, 212, .15);
  color: var(--c);
  border: 1px solid rgba(6, 182, 212, .3)
}

.role-normal {
  background: rgba(255, 255, 255, .06);
  color: var(--text2);
  border: 1px solid var(--glass-border)
}

/* ===== Inbox/Inner views ===== */
.inner-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
  width: 100%;
  gap: 12px
}

.inner-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 8px
}

.inner-topbar-left,
.inner-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap
}

.inner-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px
}

.inbox-header-info {
  display: flex;
  align-items: center;
  gap: 8px
}

.inbox-address {
  font-weight: 600;
  font-size: .88rem;
  color: var(--c);
  word-break: break-all
}

.inbox-copy-btn {
  cursor: pointer;
  color: var(--text2);
  transition: color .2s;
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: var(--r4)
}

.inbox-copy-btn:hover {
  color: var(--g)
}

/* Messages list */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 6px
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r12);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: all .2s var(--ease);
  animation: fadeUp .3s ease-out backwards
}

.message-row:hover {
  background: var(--glass-hover);
  border-color: var(--glass-border-hover)
}

.message-row.unread {
  border-left: 3px solid var(--p)
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--grad-glow);
  border: 1px solid rgba(139, 92, 246, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .78rem;
  color: var(--p-light);
  flex-shrink: 0;
  text-transform: uppercase
}

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

.msg-subject {
  font-weight: 600;
  font-size: .85rem;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.msg-from-line {
  font-size: .73rem;
  color: var(--text2)
}

.msg-preview {
  font-size: .73rem;
  color: var(--text3);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.msg-time {
  font-size: .7rem;
  color: var(--text3);
  flex-shrink: 0;
  margin-top: 2px
}

/* Message detail */
.message-detail {
  padding: 28px;
  border-radius: var(--r16)
}

.message-detail-header {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 18px
}

.message-detail-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px
}

.message-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: .8rem
}

.message-meta span:first-child {
  color: var(--c);
  font-weight: 500
}

.message-meta span:last-child {
  color: var(--text2)
}

.message-body {
  font-size: .9rem;
  line-height: 1.75;
  color: var(--text2);
  white-space: pre-wrap;
  word-break: break-word
}

.message-body-html iframe {
  width: 100%;
  min-height: 400px;
  border: 1px solid var(--glass-border);
  border-radius: var(--r8);
  background: #fff
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px
}

.empty-icon {
  width: 72px;
  height: 72px;
  border-radius: var(--r16);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--text3)
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px
}

.empty-hint {
  font-size: .83rem;
  color: var(--text2)
}

/* ===== Custom Select ===== */
.custom-select {
  position: relative
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--glass-border);
  border-radius: var(--r8);
  color: var(--text);
  cursor: pointer;
  transition: all .2s var(--ease);
  user-select: none
}

.custom-select-trigger:hover,
.custom-select.open .custom-select-trigger {
  border-color: var(--p);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, .15)
}

.custom-select-trigger svg {
  transition: transform .2s var(--ease);
  flex-shrink: 0;
  color: var(--text2)
}

.custom-select.open .custom-select-trigger svg {
  transform: rotate(180deg)
}

.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #13132a;
  border: 1px solid var(--glass-border);
  border-radius: var(--r12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .6);
  z-index: 200;
  overflow: hidden;
  display: none;
  animation: dropIn .15s var(--ease)
}

.custom-select.open .custom-select-dropdown {
  display: block
}

@keyframes dropIn {
  from {
    opacity: 0;
    transform: translateY(-6px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.custom-select-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  transition: background .15s;
  border-bottom: 1px solid var(--glass-border)
}

.custom-select-option:last-child {
  border-bottom: none
}

.custom-select-option:hover {
  background: rgba(255, 255, 255, .05)
}

.custom-select-option.selected {
  background: rgba(139, 92, 246, .1)
}

.option-desc {
  font-size: .75rem;
  color: var(--text2)
}

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fadeIn .2s ease-out
}

.modal {
  width: 100%;
  max-width: 420px;
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn .25s var(--ease);
  border-radius: var(--r16)
}

.modal-wide {
  max-width: 520px
}

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

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700
}

.modal-desc {
  color: var(--text2);
  font-size: .85rem;
  margin-bottom: 16px
}

.modal-desc strong {
  color: var(--c)
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap
}

/* User picker (for transfer/assign modals) */
.user-picker {
  display: flex;
  flex-direction: column;
  gap: 6px
}

.user-pick-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--r8);
  color: var(--text);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s var(--ease);
  width: 100%;
  text-align: left
}

.user-pick-btn:hover {
  background: var(--grad-glow);
  border-color: var(--p)
}

.user-pick-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .78rem;
  flex-shrink: 0;
  text-transform: uppercase
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  padding: 10px 20px;
  background: #13132a;
  border: 1px solid var(--glass-border);
  border-radius: var(--r8);
  color: var(--text);
  font-size: .83rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  opacity: 0;
  transition: all .25s var(--ease);
  max-width: 90vw;
  text-align: center
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0)
}

.toast.success {
  border-color: rgba(16, 185, 129, .4)
}

.toast.error {
  border-color: rgba(239, 68, 68, .4);
  color: var(--r)
}

/* ===== Spinner ===== */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

/* ===== Utils ===== */
.hidden {
  display: none !important
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(.92)
  }

  to {
    opacity: 1;
    transform: scale(1)
  }
}

/* ===== OTP / Verification Code Chip ===== */
.otp-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 12px;
  background: linear-gradient(135deg, rgba(139, 92, 246, .12), rgba(6, 182, 212, .12));
  border: 1px solid rgba(139, 92, 246, .35);
  border-radius: var(--r8);
  margin-top: 8px;
  cursor: default
}

.otp-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text2)
}

.otp-code {
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: .18em;
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-variant-numeric: tabular-nums
}

.otp-copy-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  background: rgba(139, 92, 246, .15);
  border: 1px solid rgba(139, 92, 246, .3);
  border-radius: var(--r4);
  color: var(--p-light);
  font-family: inherit;
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s var(--ease);
  white-space: nowrap
}

.otp-copy-btn:hover {
  background: rgba(139, 92, 246, .3);
  border-color: rgba(139, 92, 246, .55)
}

.otp-copy-btn svg {
  width: 11px;
  height: 11px
}

/* pulse ring on the chip */
.otp-chip::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: var(--grad);
  opacity: 0;
  animation: otpPulse 2.5s ease-in-out infinite;
  z-index: -1;
  filter: blur(6px)
}

.otp-chip {
  position: relative
}

@keyframes otpPulse {

  0%,
  100% {
    opacity: 0
  }

  50% {
    opacity: .15
  }
}

/* Message row with OTP detected */
.message-row.has-otp {
  border-left: 2.5px solid var(--p)
}

/* ===== Activity Log ===== */
.log-filters {
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px
}

.log-search-input {
  width: 100%;
  padding: 9px 13px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--glass-border);
  border-radius: var(--r8);
  color: var(--text);
  font-family: inherit;
  font-size: .85rem;
  outline: none;
  transition: border-color .2s
}

.log-search-input:focus {
  border-color: var(--p)
}

.log-search-input::placeholder {
  color: var(--text3)
}

.log-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px
}

.chip {
  padding: 5px 12px;
  border-radius: 100px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--glass-border);
  color: var(--text2);
  font-family: inherit;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s var(--ease)
}

.chip:hover {
  background: rgba(255, 255, 255, .09);
  color: var(--text);
  border-color: var(--glass-border-hover)
}

.chip-active,
.chip.active {
  background: rgba(139, 92, 246, .18);
  border-color: rgba(139, 92, 246, .4);
  color: var(--p-light)
}

/* Timeline */
.activity-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative
}

.activity-timeline::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, rgba(139, 92, 246, .3), transparent);
  border-radius: 2px
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  position: relative;
  animation: fadeUp .3s ease-out backwards
}

.log-entry:last-child {
  padding-bottom: 0
}

.log-dot {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  border: 2px solid var(--bg)
}

.log-dot svg {
  width: 16px;
  height: 16px
}

/* Action color coding */
.log-dot-login {
  background: rgba(16, 185, 129, .2);
  color: var(--g)
}

.log-dot-signup {
  background: rgba(6, 182, 212, .2);
  color: var(--c)
}

.log-dot-generate {
  background: rgba(139, 92, 246, .2);
  color: var(--p-light)
}

.log-dot-assign {
  background: rgba(139, 92, 246, .2);
  color: var(--p-light)
}

.log-dot-delete {
  background: rgba(239, 68, 68, .2);
  color: var(--r)
}

.log-dot-transfer {
  background: rgba(245, 158, 11, .2);
  color: #fbbf24
}

.log-dot-edit {
  background: rgba(6, 182, 212, .2);
  color: var(--c)
}

.log-dot-received {
  background: rgba(16, 185, 129, .2);
  color: var(--g)
}

.log-dot-failed {
  background: rgba(239, 68, 68, .15);
  color: var(--r)
}

.log-dot-default {
  background: rgba(255, 255, 255, .06);
  color: var(--text2)
}

.log-content {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--r12);
  transition: border-color .2s
}

.log-content:hover {
  border-color: var(--glass-border-hover)
}

.log-content-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap
}

.log-action-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 2px 8px;
  border-radius: 100px
}

.log-user {
  font-weight: 700;
  font-size: .85rem
}

.log-target {
  font-weight: 500;
  font-size: .82rem;
  color: var(--c)
}

.log-details {
  font-size: .78rem;
  color: var(--text2);
  margin-top: 2px
}

.log-time {
  font-size: .7rem;
  color: var(--text3);
  flex-shrink: 0;
  white-space: nowrap
}

/* Action label colors */
.label-login {
  background: rgba(16, 185, 129, .15);
  color: var(--g)
}

.label-signup {
  background: rgba(6, 182, 212, .15);
  color: var(--c)
}

.label-generate {
  background: rgba(139, 92, 246, .15);
  color: var(--p-light)
}

.label-assign {
  background: rgba(139, 92, 246, .15);
  color: var(--p-light)
}

.label-delete {
  background: rgba(239, 68, 68, .15);
  color: var(--r)
}

.label-transfer {
  background: rgba(245, 158, 11, .15);
  color: #fbbf24
}

.label-edit {
  background: rgba(6, 182, 212, .15);
  color: var(--c)
}

.label-received {
  background: rgba(16, 185, 129, .15);
  color: var(--g)
}

.label-failed {
  background: rgba(239, 68, 68, .12);
  color: var(--r)
}

.label-default {
  background: rgba(255, 255, 255, .06);
  color: var(--text2)
}

/* ===== Responsive ===== */

/* Tablet landscape */
@media(max-width:1024px) {
  :root {
    --sidebar-w: 210px
  }

  .main-content {
    margin-left: calc(var(--sidebar-w) + 16px);
    padding: 16px 16px 16px 0
  }

  .users-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr))
  }
}

/* Tablet portrait & below — collapse sidebar into drawer */
@media(max-width:768px) {

  /* Dashboard becomes a column stack, NOT row */
  #dashboard-view {
    flex-direction: column !important
  }

  /* Sidebar becomes a fixed drawer off-screen to the LEFT */
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 260px;
    border-radius: 0;
    z-index: 30;
    transition: left .3s var(--ease);
    box-shadow: none;
  }

  .sidebar.mobile-open {
    left: 0;
    box-shadow: 0 0 40px rgba(0, 0, 0, .8)
  }

  /* Show mobile topbar, collapse main */
  .mobile-topbar {
    display: flex !important
  }

  .main-content {
    margin-left: 0 !important;
    padding: 0 10px 20px;
    width: 100%;
  }

  .stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px
  }

  .form-row-2 {
    grid-template-columns: 1fr
  }

  .modal-wide {
    max-width: 95vw
  }

  .inner-layout {
    padding: 10px
  }
}

/* Phone */
@media(max-width:520px) {
  html {
    font-size: 15px
  }

  .auth-card {
    padding: 20px
  }

  .auth-brand {
    font-size: 1.3rem
  }

  .auth-logo {
    flex-direction: column;
    text-align: center;
    gap: 10px
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px
  }

  .stat-card {
    padding: 12px 14px
  }

  .stat-value {
    font-size: 1.2rem
  }

  .email-row {
    padding: 11px 13px;
    gap: 10px
  }

  .email-row-right {
    gap: 5px
  }

  /* Page header: title above, button below */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px
  }

  .page-header>div {
    order: 1
  }

  .page-header>.btn {
    order: 2;
    justify-content: center;
    width: 100%
  }

  .page-header>.btn-primary {
    display: flex
  }

  .message-detail {
    padding: 16px
  }

  .modal {
    padding: 18px;
    border-radius: var(--r12)
  }

  .modal-actions {
    flex-direction: column
  }

  .modal-actions .btn {
    justify-content: center
  }

  .users-grid {
    grid-template-columns: 1fr
  }

  .inner-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px
  }

  .inner-topbar-left,
  .inner-topbar-right {
    justify-content: flex-start;
    flex-wrap: wrap
  }
}

/* Small phones */
@media(max-width:390px) {
  html {
    font-size: 14px
  }

  .stats-row {
    grid-template-columns: 1fr
  }

  .email-row-addr {
    font-size: .8rem
  }

  .auth-card {
    padding: 16px
  }

  .mobile-topbar {
    margin: 6px;
    padding: 8px 10px
  }
}

/* Notch/safe area */
@supports(padding:max(0px)) {
  .sidebar {
    padding-top: max(0px, env(safe-area-inset-top))
  }

  .main-content {
    padding-bottom: max(20px, env(safe-area-inset-bottom))
  }

  .mobile-topbar {
    margin-top: max(8px, env(safe-area-inset-top))
  }
}