:root {
  --bg: #09090b;
  --surface: #121215;
  --card-bg: rgba(24, 24, 27, 0.65);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover: rgba(39, 39, 42, 0.7);
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --accent: linear-gradient(135deg, #ffffff 0%, #a1a1aa 100%);
  --accent-danger: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  --safe-bottom: env(safe-area-inset-bottom, 16px);
  --sidebar-width: 260px;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Unbounded', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-user-select: text;
  user-select: text;
}
button, .btn, .nav-btn, .sidebar-btn, .fab, .brand-icon {
  -webkit-user-select: none;
  user-select: none;
}
#view-mail-body, .mail-item, code, pre, .dns-box, .card, input, textarea, select {
  -webkit-user-select: text !important;
  user-select: text !important;
}
#app {
  min-height: 100vh;
  width: 100%;
}
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}
.sidebar {
  display: none;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--card-border);
  padding: 24px 18px;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
}
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: calc(76px + var(--safe-bottom));
}
@media (min-width: 860px) {
  .sidebar { display: flex; }
  .bottom-nav { display: none !important; }
  .header-mobile-brand { display: none; }
  .main-wrapper { padding-bottom: 24px; }
  .content-area { max-width: 1200px; margin: 0 auto; width: 100%; padding: 28px 32px; }
}
@media (max-width: 859px) {
  .content-area { padding: 16px 20px; width: 100%; }
}
.header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--card-border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, #27272a 0%, #18181b 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.brand-icon img,
.brand-icon svg {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
}
.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-weight: 500;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 24px;
  flex: 1;
  overflow-y: auto;
}
.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}
.sidebar-btn.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}
.sidebar-btn.active svg { stroke: #fff; }
.sidebar-user {
  margin-top: auto;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 16px;
  backdrop-filter: blur(12px);
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #09090b;
}
.btn-primary:active { transform: scale(0.97); }
.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--card-border);
}
.btn-secondary:active { transform: scale(0.97); }
.btn-danger {
  background: var(--accent-danger);
  color: #fff;
}
.btn-danger:active { transform: scale(0.97); }
.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
}
.btn-success:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.badge-status {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.badge-blocked {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.badge-owner {
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.05) 100%);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
}
.user-card {
  padding: 16px 18px;
  background: rgba(24, 24, 27, 0.5);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  margin-bottom: 12px;
  transition: all 0.2s;
}
.user-card:hover {
  background: var(--card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}
.mail-item {
  padding: 16px 18px;
  background: rgba(24, 24, 27, 0.5);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 14px;
}
.mail-item:hover {
  background: var(--card-hover);
  border-color: rgba(255, 255, 255, 0.18);
}
.mail-item.unread {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(39, 39, 42, 0.6);
}
.mail-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.mail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.mail-avatar img.avatar-mask {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
  padding: 4px;
  opacity: 0.9;
}
.mail-content { flex: 1; min-width: 0; }
.mail-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.mail-sender {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mail-time {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 10px;
}
.mail-subject {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fab {
  position: fixed;
  right: 24px;
  bottom: calc(88px + var(--safe-bottom));
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: var(--accent);
  color: #09090b;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  border: none;
  cursor: pointer;
  z-index: 30;
  transition: transform 0.2s;
}
@media (min-width: 860px) {
  .fab { bottom: 32px; right: 32px; }
}
.fab:active { transform: scale(0.92); }
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(9, 9, 11, 0.94);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
}
.nav-btn {
  flex: 1;
  max-width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 9px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 2px;
  border-radius: 10px;
  transition: all 0.15s ease;
}
.nav-btn.active { color: #fff; }
.nav-btn.active svg { stroke: #fff; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  display: none;
  align-items: flex-end;
  z-index: 100;
}
@media (min-width: 860px) {
  .modal-overlay { align-items: center; justify-content: center; padding: 24px; }
  .modal-sheet { max-width: 900px; width: 95%; max-height: 90vh; border-radius: 20px !important; }
}
#modal-view-mail .modal-sheet {
  max-width: 1140px;
  width: 96%;
  height: 92vh;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  padding: 24px 28px;
  border-radius: 20px !important;
  transition: all 0.2s ease;
}
#modal-view-mail.fullscreen .modal-sheet {
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  padding: 20px 32px;
}
#view-mail-body {
  flex: 1;
  min-height: 0;
  border-radius: 14px;
  padding: 28px;
  background: #ffffff;
  color: #111827;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  line-height: 1.6;
  word-break: break-word;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.06);
  user-select: text !important;
  -webkit-user-select: text !important;
}
#view-mail-body.plain-text {
  background: rgba(255,255,255,0.03);
  color: #f4f4f5;
  border: 1px solid var(--card-border);
  font-family: inherit;
  font-size: 13px;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: #121215;
  border: 1px solid var(--card-border);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px 22px calc(24px + var(--safe-bottom));
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.input-group { margin-bottom: 14px; }
.input-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}
.input-field {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}
.input-field:focus { border-color: rgba(255, 255, 255, 0.4); }
select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 36px;
  cursor: pointer;
}
select.input-field option {
  background: #18181b;
  color: #fff;
  padding: 8px;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 11px;
  color: #f4f4f5;
  max-width: 280px;
}
.attachment-chip .att-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip .att-remove {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 0 4px;
  font-size: 13px;
  line-height: 1;
}
.mailbox-badge {
  display: inline-block;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: #a1a1aa;
  font-weight: 500;
  margin-top: 4px;
}
textarea.input-field { min-height: 120px; resize: vertical; }
.dns-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px;
  font-family: monospace;
  font-size: 11px;
  word-break: break-all;
  color: #a1a1aa;
  margin-top: 6px;
  user-select: all;
}
.progress-bar {
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}
.stalwart-frame-container {
  width: 100%;
  height: calc(100vh - 120px);
  min-height: 600px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: #000;
}
.stalwart-frame-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(18, 18, 21, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(16px);
  color: #fff;
  padding: 10px 18px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 200;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.pending-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 30px 24px;
}
.pending-icon {
  width: 96px;
  height: 96px;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.16) 0%, rgba(239, 68, 68, 0.04) 100%);
  border: 1px solid rgba(239, 68, 68, 0.35);
  box-shadow: 0 16px 36px rgba(239, 68, 68, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}
.pending-icon svg,
.pending-icon img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}
.blocked-id-card {
  width: 100%;
  max-width: 380px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 14px 18px;
  text-align: left;
  backdrop-filter: blur(12px);
}
.admin-filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.filter-btn {
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.filter-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.filter-btn.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}
.user-meta-block {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.meta-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}
.meta-val-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.mb-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 8px;
  word-break: break-all;
}
.meta-none {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.meta-limits-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.limit-tag {
  font-size: 11px;
  color: #d4d4d8;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.limit-tag b {
  color: #fff;
}
.avatar-crop-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin: 16px 0;
}
.avatar-crop-preview-box {
  width: 140px;
  height: 140px;
  border-radius: 24px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-crop-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.1s ease-out;
}
