/* ==========================================================================
   CLOUDROUTE MAIL - "PROFESSIONAL POLISH" THEME STYLESHEET
   Clean, modern enterprise styling with Slate-900 sidebar, #F8FAFC canvas,
   crisp white cards, Blue-600 accents, refined typography and smooth transitions.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. ROOT VARIABLES & COLOR PALETTE
   -------------------------------------------------------------------------- */
:root {
  /* Canvas & Card Surfaces (Professional Polish Light) */
  --bg-app: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --bg-subtle: #F1F5F9;
  
  /* Sidebar Palette */
  --bg-sidebar: #0F172A;
  --bg-sidebar-hover: #1E293B;
  --bg-sidebar-active: rgba(37, 99, 235, 0.12);
  --sidebar-text: #94A3B8;
  --sidebar-text-active: #60A5FA;
  --sidebar-border: #1E293B;
  
  /* Borders & Dividers */
  --border-color: #E2E8F0;
  --border-subtle: #F1F5F9;
  --border-focus: #2563EB;
  
  /* Text Hierarchy */
  --text-main: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --text-inverse: #FFFFFF;

  /* Brand Accents */
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-subtle: rgba(37, 99, 235, 0.08);
  --primary-border: #BFDBFE;
  
  /* Status Colors */
  --success: #10B981;
  --success-subtle: #ECFDF5;
  --success-border: #A7F3D0;
  --success-text: #047857;

  --warning: #F59E0B;
  --warning-subtle: #FFFBEB;
  --warning-border: #FDE68A;
  --warning-text: #B45309;

  --danger: #EF4444;
  --danger-hover: #DC2626;
  --danger-subtle: #FEF2F2;
  --danger-border: #FECACA;
  --danger-text: #B91C1C;

  --info: #0284C7;
  --info-subtle: #F0F9FF;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Dimensions & Spacing */
  --sidebar-width: 256px;
  --header-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);
  --shadow-2xl: 0 25px 50px -12px rgba(15, 23, 42, 0.25);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Theme */
[data-theme="dark"] {
  --bg-app: #0B0F17;
  --bg-card: #131B2A;
  --bg-card-hover: #1A2436;
  --bg-subtle: #172033;
  
  --bg-sidebar: #090D15;
  --bg-sidebar-hover: #131B2A;
  --bg-sidebar-active: rgba(59, 130, 246, 0.15);
  --sidebar-text: #94A3B8;
  --sidebar-text-active: #60A5FA;
  --sidebar-border: #172033;
  
  --border-color: #1E293B;
  --border-subtle: #172033;
  --border-focus: #60A5FA;
  
  --text-main: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --text-light: #64748B;
  --text-inverse: #0B0F17;

  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --primary-subtle: rgba(59, 130, 246, 0.15);
  --primary-border: rgba(59, 130, 246, 0.3);

  --success: #34D399;
  --success-subtle: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.3);
  --success-text: #34D399;

  --warning: #FBBF24;
  --warning-subtle: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.3);
  --warning-text: #FBBF24;

  --danger: #F87171;
  --danger-hover: #EF4444;
  --danger-subtle: rgba(239, 68, 68, 0.15);
  --danger-border: rgba(239, 68, 68, 0.3);
  --danger-text: #F87171;

  --info: #38BDF8;
  --info-subtle: rgba(56, 189, 248, 0.12);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}

/* --------------------------------------------------------------------------
   2. BASE & RESET
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  overflow-y: auto;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
}

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

ul, ol {
  list-style: none;
}

code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.875em;
}

[data-theme="dark"] code {
  background: rgba(255, 255, 255, 0.08);
}

.text-mono {
  font-family: var(--font-mono);
}

.font-medium {
  font-weight: 500;
}

.hidden {
  display: none !important;
}

.sm-only {
  display: none;
}

/* Animation helpers */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.25s ease-out forwards;
}

/* App root container */
.app-root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   3. BUTTONS & UI CONTROLS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.25rem;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary);
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  color: var(--text-main);
  border-color: #CBD5E1;
}

.btn-dark {
  background-color: #0F172A;
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.btn-dark:hover:not(:disabled) {
  background-color: #1E293B;
  box-shadow: var(--shadow-md);
}

.btn-danger {
  background-color: var(--danger);
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--danger-hover);
}

.btn-danger-soft {
  background-color: var(--danger-subtle);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.btn-danger-soft:hover:not(:disabled) {
  background-color: var(--danger);
  color: #FFFFFF;
  border-color: var(--danger);
}

.btn-link {
  color: var(--primary);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 0.9375rem;
  font-weight: 600;
}

.btn-block {
  width: 100%;
}

.btn-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-icon-secondary {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  transition: all var(--transition-fast);
  cursor: pointer;
  padding: 0;
}

.btn-icon-secondary svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  display: block;
  flex-shrink: 0;
}

.btn-icon-secondary:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
  border-color: #CBD5E1;
}

.btn-icon-secondary.starred {
  color: var(--warning);
  border-color: var(--warning-border);
  background-color: var(--warning-subtle);
}

.btn-icon-secondary.starred svg {
  fill: currentColor;
}

.btn-icon-secondary.text-danger:hover {
  color: var(--danger);
  border-color: var(--danger-border);
  background-color: var(--danger-subtle);
}

/* Spinner */
.spinner-svg {
  animation: spin 1s linear infinite;
  width: 18px;
  height: 18px;
}

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

.opacity-25 { opacity: 0.25; }
.opacity-75 { opacity: 0.75; }

/* --------------------------------------------------------------------------
   4. FORM INPUTS & SWITCHES
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.form-label-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-sublabel {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.form-help-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

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

.form-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.form-input.has-left-icon {
  padding-left: 38px;
}

.form-input.has-right-icon {
  padding-right: 38px;
}

.input-icon {
  position: absolute;
  left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  pointer-events: none;
}

.input-action-btn {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.input-action-btn:hover {
  color: var(--text-main);
}

/* Custom Checkbox */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkbox-custom {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid #CBD5E1;
  background-color: var(--bg-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.checkbox-label input:checked ~ .checkbox-custom {
  background-color: var(--primary);
  border-color: var(--primary);
}

.checkbox-label input:checked ~ .checkbox-custom::after {
  content: '';
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}

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

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #CBD5E1;
  transition: var(--transition-normal);
  border-radius: var(--radius-pill);
}

.slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: var(--transition-normal);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

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

input:focus-visible + .slider {
  outline: 2px solid var(--border-focus);
}

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

/* Custom Select */
.custom-select {
  padding: 6px 30px 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all var(--transition-fast);
}

.custom-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Alert Banner */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  margin-bottom: 16px;
}

.alert-danger {
  background-color: var(--danger-subtle);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

/* Badges & Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-success {
  background-color: #ECFDF5;
  color: #047857;
  border: 1px solid #A7F3D0;
}

.badge-success-soft {
  background-color: var(--success-subtle);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.badge-neutral {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10B981;
  display: inline-block;
}

.dot-pulse {
  animation: pulse-dot 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* --------------------------------------------------------------------------
   5. AUTHENTICATION / LOGIN VIEW
   -------------------------------------------------------------------------- */
.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: var(--bg-app);
}

.auth-card-wrapper {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-brand-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo-box {
  display: inline-flex;
  margin-bottom: 12px;
}

.brand-icon {
  width: 48px;
  height: 48px;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.auth-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.auth-card {
  width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.auth-card-top {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.security-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background-color: var(--primary-subtle);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
}

.auth-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.auth-demo-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.auth-footer {
  margin-top: 24px;
  text-align: center;
}

.auth-trust-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.trust-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.trust-divider {
  opacity: 0.5;
}

.auth-copyright {
  font-size: 0.6875rem;
  color: var(--text-light);
  margin-top: 8px;
}

/* --------------------------------------------------------------------------
   6. DASHBOARD LAYOUT & SIDEBAR
   -------------------------------------------------------------------------- */
.dashboard-view {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: #E2E8F0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  border-right: 1px solid var(--sidebar-border);
  transition: transform var(--transition-normal);
}

.sidebar-brand {
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-flex {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-small {
  width: 32px;
  height: 32px;
  background-color: #2563EB;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
}

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

.brand-title {
  font-weight: 700;
  font-size: 1.125rem;
  color: #FFFFFF;
  letter-spacing: -0.02em;
}

.brand-domain {
  font-size: 0.6875rem;
  color: #64748B;
  font-family: var(--font-mono);
}

.sidebar-status-pill {
  margin: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
}

.sidebar-status-pill .status-label {
  font-weight: 600;
  color: #F8FAFC;
  flex-grow: 1;
}

.status-badge-sub {
  font-size: 0.6875rem;
  background: rgba(37, 99, 235, 0.2);
  color: #60A5FA;
  padding: 1px 6px;
  border-radius: 4px;
}

.sidebar-nav {
  flex-grow: 1;
  padding: 12px 16px;
  overflow-y: auto;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-link:hover {
  background-color: var(--bg-sidebar-hover);
  color: #FFFFFF;
}

.nav-link.active {
  background-color: var(--bg-sidebar-active);
  color: var(--sidebar-text-active);
  font-weight: 600;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-text {
  flex-grow: 1;
  text-align: left;
}

.nav-badge {
  background-color: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}

.nav-link.active .nav-badge {
  background-color: #2563EB;
  color: #FFFFFF;
}

.nav-pill-status {
  font-size: 0.6875rem;
  color: #34D399;
  background: rgba(16, 185, 129, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Diagnostics widget in sidebar */
.sidebar-diagnostics {
  margin: 8px 16px 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.6875rem;
}

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

.diag-title {
  color: #94A3B8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.diag-badge-ok {
  background: rgba(16, 185, 129, 0.2);
  color: #34D399;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
}

.diag-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #64748B;
}

.diag-row {
  display: flex;
  justify-content: space-between;
}

.diag-val {
  color: #CBD5E1;
  font-family: var(--font-mono);
}

.sidebar-storage {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.storage-text-row {
  display: flex;
  justify-content: space-between;
  color: #94A3B8;
  margin-bottom: 4px;
}

.storage-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.storage-fill {
  height: 100%;
  background: #38BDF8;
  border-radius: 2px;
}

/* User Profile footer in sidebar */
.sidebar-user-footer {
  padding: 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-sidebar);
}

.user-profile-row {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #6366F1;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-email-text {
  font-size: 0.6875rem;
  color: #64748B;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.btn-icon-logout {
  color: #94A3B8;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-icon-logout:hover {
  color: #F87171;
  background-color: rgba(239, 68, 68, 0.1);
}

/* --------------------------------------------------------------------------
   7. MAIN CONTENT WRAPPER & HEADER
   -------------------------------------------------------------------------- */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.app-header {
  height: var(--header-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.header-top-status-badge,
.pane-top-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background-color: var(--success-subtle);
  color: var(--success-text);
  border: 1px solid var(--success-border);
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}

.header-top-status-badge.disabled,
.pane-top-status-badge.disabled {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  border-color: var(--border-color);
}

.status-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--success);
  display: inline-block;
}

.header-top-status-badge.disabled .status-indicator-dot,
.pane-top-status-badge.disabled .status-indicator-dot {
  background-color: var(--text-muted);
}

.header-page-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.header-page-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--transition-fast);
  position: relative;
}

.header-btn-icon:hover {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
}

.notif-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  background-color: var(--primary);
  border: 1.5px solid var(--bg-card);
  border-radius: 50%;
}

.header-account-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  transition: all var(--transition-fast);
}

.header-account-pill:hover {
  background-color: var(--bg-subtle);
  border-color: #CBD5E1;
}

.account-pill-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #6366F1;
  color: #FFFFFF;
  font-size: 0.6875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.account-pill-email {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.chevron-icon {
  color: var(--text-muted);
}

/* POPOVER DROPDOWNS */
.popover-wrapper {
  position: relative;
}

.popover-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2xl);
  z-index: 50;
  animation: dropdown-fade-in 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dropdown-fade-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.account-dropdown {
  width: 250px;
}

.account-dropdown-header {
  padding: 14px 16px;
}

.acc-drop-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
}

.acc-drop-email {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  font-family: var(--font-mono);
  display: block;
  margin-top: 2px;
  word-break: break-all;
}

.acc-drop-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.6875rem;
  color: var(--success);
  font-weight: 500;
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-color);
}

.dropdown-menu-list {
  padding: 6px;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.dropdown-item:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.dropdown-footer {
  padding: 6px;
}

.dropdown-item.item-danger:hover {
  background-color: var(--danger-subtle);
  color: var(--danger);
}

/* Notifications Dropdown */
.notif-dropdown {
  width: 320px;
}

.dropdown-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.dropdown-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}

.notif-list {
  max-height: 280px;
  overflow-y: auto;
}

.notif-item {
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color var(--transition-fast);
}

.notif-item:hover {
  background-color: var(--bg-subtle);
}

.notif-icon-box {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notif-icon-box.success {
  background-color: var(--success-subtle);
  color: var(--success);
}

.notif-icon-box.info {
  background-color: var(--info-subtle);
  color: var(--info);
}

.notif-content {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.notif-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  display: block;
  margin-top: 4px;
}

/* Main Content Pane */
.app-main-content {
  padding: 32px;
  flex-grow: 1;
  background-color: var(--bg-app);
}

.content-pane {
  display: block;
}

/* --------------------------------------------------------------------------
   8. INBOX SCREEN
   -------------------------------------------------------------------------- */
.inbox-toolbar-card {
  background-color: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.toolbar-search-col {
  flex-grow: 1;
  max-width: 320px;
}

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

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-field {
  width: 100%;
  padding: 8px 34px 8px 38px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background-color: #F1F5F9;
  color: var(--text-main);
  font-size: 0.875rem;
  outline: none;
  transition: all var(--transition-fast);
}

[data-theme="dark"] .search-field {
  background-color: #1E293B;
}

.search-field:focus {
  background-color: var(--bg-card);
  border-color: #3B82F6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.clear-search-btn {
  position: absolute;
  right: 12px;
  color: var(--text-muted);
  padding: 2px;
}

.clear-search-btn:hover {
  color: var(--text-main);
}

.toolbar-actions-col {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Batch Action Bar */
.batch-action-bar {
  background-color: var(--primary-subtle);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-lg);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  animation: fadeIn 150ms ease-out;
}

.batch-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.batch-count-text {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary);
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Email List Card (Clean divide-y container) */
.email-list-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.email-rows-container {
  display: flex;
  flex-direction: column;
}

/* Email Row Item */
.email-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  user-select: none;
}

.email-row:last-child {
  border-bottom: none;
}

.email-row:hover {
  background-color: #F8FAFC;
}

[data-theme="dark"] .email-row:hover {
  background-color: #1A2436;
}

/* Unread vs Read */
.email-row.unread {
  background-color: rgba(248, 250, 252, 0.6);
}

[data-theme="dark"] .email-row.unread {
  background-color: rgba(59, 130, 246, 0.04);
}

.email-row.read {
  background-color: var(--bg-card);
}

.email-row-select {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.email-row-star {
  display: flex;
  align-items: center;
  color: var(--text-light);
  transition: color var(--transition-fast);
  padding: 2px;
}

.email-row-star:hover,
.email-row-star.starred {
  color: #F59E0B;
}

.unread-dot-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #3B82F6;
  flex-shrink: 0;
}

.email-row.read .unread-dot-indicator {
  background-color: transparent;
}

.email-sender-col {
  width: 150px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  overflow: hidden;
}

.sender-mini-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: #EFF6FF;
  color: #2563EB;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

[data-theme="dark"] .sender-mini-avatar {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
}

.sender-name-text {
  font-size: 0.875rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-row.unread .sender-name-text {
  font-weight: 700;
  color: #0F172A;
}

[data-theme="dark"] .email-row.unread .sender-name-text {
  color: #F8FAFC;
}

.email-row.read .sender-name-text {
  font-weight: 500;
  color: #475569;
}

[data-theme="dark"] .email-row.read .sender-name-text {
  color: #94A3B8;
}

.email-content-col {
  flex-grow: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.email-subject-text {
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-row.unread .email-subject-text {
  font-weight: 700;
  color: #0F172A;
}

[data-theme="dark"] .email-row.unread .email-subject-text {
  color: #F8FAFC;
}

.email-row.read .email-subject-text {
  font-weight: 400;
  color: #334155;
}

[data-theme="dark"] .email-row.read .email-subject-text {
  color: #CBD5E1;
}

.email-snippet-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}

.tag-forwarded-pill {
  font-size: 0.6875rem;
  background: var(--success-subtle);
  color: var(--success-text);
  border: 1px solid var(--success-border);
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  font-weight: 600;
}

.email-meta-col {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.attachment-icon-indicator {
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.email-time-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: var(--font-mono);
}

.email-row-actions {
  display: none;
  align-items: center;
  gap: 4px;
}

.email-row:hover .email-row-actions {
  display: flex;
}

.email-row:hover .email-time-text {
  display: none;
}

.row-action-btn {
  padding: 4px;
  border-radius: 4px;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.row-action-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.row-action-btn.btn-delete-row:hover {
  color: var(--danger);
}

/* Skeleton Loading */
.email-skeleton-list {
  display: flex;
  flex-direction: column;
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.sk-box {
  background: linear-gradient(90deg, var(--border-subtle) 25%, var(--bg-card-hover) 50%, var(--border-subtle) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  height: 16px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.sk-check { width: 16px; height: 16px; }
.sk-avatar { width: 28px; height: 28px; border-radius: 50%; }
.sk-sender { width: 120px; }
.sk-subject { flex-grow: 1; }
.sk-time { width: 60px; }

/* Empty State */
.empty-state-box {
  padding: 64px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-icon-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.empty-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 420px;
  margin-bottom: 20px;
  line-height: 1.6;
}

.email-list-footer {
  padding: 12px 20px;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.inbox-secure-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--success);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   9. EMAIL READER SCREEN
   -------------------------------------------------------------------------- */
.reader-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 28px;
}

.reader-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reader-subject-box {
  margin-bottom: 20px;
}

.subject-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.reader-subject-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.reader-sender-box {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}

.sender-avatar-large {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #2563EB;
  color: #FFFFFF;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sender-meta-col {
  flex-grow: 1;
}

.sender-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sender-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-main);
}

.sender-email {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.sender-recipient-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

.recipient-label {
  color: var(--text-muted);
}

.recipient-value {
  font-family: var(--font-mono);
  font-weight: 500;
}

.meta-dot {
  color: var(--text-light);
}

.meta-date {
  color: var(--text-muted);
}

.sender-security-badges {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.security-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  background-color: var(--success-subtle);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.routing-event-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background-color: var(--primary-subtle);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.event-icon-box {
  color: var(--primary);
  flex-shrink: 0;
}

.event-details {
  font-size: 0.8125rem;
  color: var(--text-main);
}

.event-title {
  font-weight: 600;
}

/* Email Body Typography */
.reader-body-container {
  padding: 24px 0;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
}

.reader-body-container p {
  margin-bottom: 16px;
}

.reader-body-container .verification-code-card {
  margin: 24px 0;
  padding: 24px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  text-align: center;
}

.reader-body-container .code-display {
  font-family: var(--font-mono);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--primary);
  margin: 12px 0;
}

.reader-body-container .alert-box-info {
  background-color: var(--info-subtle);
  border-left: 4px solid var(--info);
  padding: 14px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 18px 0;
  font-size: 0.875rem;
}

.reader-body-container .email-signature {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-color);
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Attachments */
.reader-attachments-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--border-color);
}

.attachments-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 14px;
}

.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.attachment-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.attachment-card:hover {
  background-color: var(--bg-card);
  border-color: #CBD5E1;
}

.att-meta {
  display: flex;
  flex-direction: column;
}

.att-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}

.att-size {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.reader-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 20px;
}

.quick-forward-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
}

.qf-label {
  color: var(--text-muted);
}

.qf-target {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-main);
}

/* --------------------------------------------------------------------------
   10. FORWARDING MANAGEMENT & FLOW VISUALIZER
   -------------------------------------------------------------------------- */
.forwarding-container-wrap {
  max-width: 672px; /* max-w-2xl */
  margin: 0 auto;
}

.page-intro-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.pane-headline {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.pane-subtext {
  font-size: 0.8125rem;
  color: var(--text-muted);
  max-width: 600px;
  margin-top: 4px;
}

.routing-arch-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background-color: var(--primary-subtle);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Flow Visualizer */
.routing-visualizer-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.flow-node {
  display: flex;
  align-items: center;
  gap: 14px;
}

.node-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  flex-shrink: 0;
}

.node-icon.bg-slate { background: #0F172A; }
.node-icon.bg-indigo { background: #2563EB; }
.node-icon.disabled { background: #64748B; opacity: 0.6; }

.node-meta {
  display: flex;
  flex-direction: column;
}

.node-title {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.node-val {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.flow-connector {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px;
  position: relative;
}

.flow-line {
  width: 100%;
  height: 2px;
  background-color: var(--border-color);
  position: relative;
}

.flow-line.active {
  background: linear-gradient(90deg, #2563EB, #38BDF8);
}

.flow-badge {
  position: absolute;
  top: -12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

/* Settings & Forwarding Cards (rounded-2xl) */
.settings-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-2xl);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}

.mt-6 { margin-top: 24px; }

.card-header-flex {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.card-section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
}

.title-with-pill {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-section-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.card-divider {
  height: 1px;
  background-color: var(--border-subtle);
  margin: 24px 0;
}

/* Forwarding destination box */
.destination-box-container {
  padding: 16px;
  background-color: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-top: 16px;
}

[data-theme="dark"] .destination-box-container {
  background-color: #172033;
}

.destination-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.flex-grow { flex-grow: 1; }

.destination-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.dest-info-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--success);
  font-weight: 600;
}

.action-btn-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Rules List */
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.rule-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background-color: var(--bg-subtle);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.rule-item:hover {
  background-color: var(--bg-card);
  border-color: #CBD5E1;
}

.rule-content {
  display: flex;
  flex-direction: column;
}

.rule-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

.rule-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Data Table */
.table-responsive {
  overflow-x: auto;
  margin-top: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.8125rem;
}

.data-table th {
  padding: 10px 14px;
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.status-chip.success {
  background-color: var(--success-subtle);
  color: var(--success);
}

/* --------------------------------------------------------------------------
   11. SETTINGS SCREEN
   -------------------------------------------------------------------------- */
.settings-container-wrap {
  max-width: 672px; /* max-w-2xl */
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.settings-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-top: 16px;
}

.setting-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-value-box {
  padding: 10px 14px;
  background-color: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
}

[data-theme="dark"] .field-value-box {
  background-color: #172033;
  color: #CBD5E1;
}

.security-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.sec-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  display: block;
}

.sec-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.security-chip-large {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background-color: var(--success-subtle);
  border: 1px solid var(--success-border);
  color: var(--success-text);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
}

.security-sessions-section {
  margin-top: 16px;
}

.sub-section-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 10px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.session-icon {
  color: var(--text-muted);
  margin-right: 12px;
}

.session-meta {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.session-device {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}

.session-details {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* DNS Records */
.dns-records-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.dns-row {
  display: grid;
  grid-template-columns: 50px 140px 1fr 90px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
}

.dns-type {
  font-weight: 700;
  font-size: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: 4px;
  text-align: center;
  color: var(--primary);
}

.dns-host {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.dns-val {
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.dns-status {
  text-align: right;
}

/* Theme Options */
.theme-picker-row {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.theme-option-card {
  flex: 1;
  max-width: 180px;
  padding: 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-card);
  transition: all var(--transition-fast);
}

.theme-option-card:hover {
  border-color: #CBD5E1;
}

.theme-option-card input[type="radio"] {
  display: none;
}

.theme-option-card:has(input:checked) {
  border-color: var(--primary);
  background-color: var(--primary-subtle);
}

.theme-preview-box {
  width: 100%;
  height: 60px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
}

.light-preview .tp-nav { width: 30%; background: #0F172A; }
.light-preview .tp-body { width: 70%; background: #F8FAFC; }

.dark-preview .tp-nav { width: 30%; background: #090D15; }
.dark-preview .tp-body { width: 70%; background: #131B2A; }

.theme-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}

/* --------------------------------------------------------------------------
   12. MODALS SYSTEM
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 150ms ease-out;
}

.modal-dialog {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: modal-scale 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modal-scale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 20px 24px 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.modal-icon-header {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-icon-header.danger {
  background-color: var(--danger-subtle);
  color: var(--danger);
}

.modal-icon-header.primary {
  background-color: var(--primary-subtle);
  color: var(--primary);
}

.modal-title-col {
  flex-grow: 1;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-close-btn {
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.modal-body {
  padding: 20px 24px;
}

.modal-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.modal-highlight-box {
  margin: 14px 0;
  padding: 12px 16px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  color: var(--text-main);
  text-align: center;
}

.modal-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-footer {
  padding: 16px 24px;
  background-color: var(--bg-subtle);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Password Strength Meter in Modal */
.strength-meter-box {
  margin-top: 8px;
}

.strength-bar-track {
  height: 4px;
  background-color: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.strength-bar-fill {
  height: 100%;
  transition: all var(--transition-normal);
}

.strength-weak { width: 25%; background-color: var(--danger); }
.strength-fair { width: 60%; background-color: var(--warning); }
.strength-strong { width: 100%; background-color: var(--success); }

.strength-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  margin-top: 4px;
}

.strength-caption { color: var(--text-muted); }
.strength-name { font-weight: 600; color: var(--text-main); }

/* --------------------------------------------------------------------------
   13. TOAST NOTIFICATION SYSTEM
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: 100%;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background-color: #0F172A;
  color: #FFFFFF;
  border-radius: var(--radius-xl);
  padding: 14px 18px;
  box-shadow: var(--shadow-2xl);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toast-slide-in 200ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-icon svg {
  width: 16px;
  height: 16px;
}

.toast-content {
  flex-grow: 1;
}

.toast-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #FFFFFF;
}

.toast-desc {
  font-size: 0.75rem;
  color: #94A3B8;
  margin-top: 2px;
}

.toast-close-btn {
  color: #64748B;
  padding: 2px;
  border-radius: 4px;
}

.toast-close-btn:hover {
  color: #FFFFFF;
}

.toast-success .toast-icon { color: #34D399; }
.toast-error .toast-icon { color: #F87171; }
.toast-warning .toast-icon { color: #FBBF24; }
.toast-info .toast-icon { color: #60A5FA; }

/* --------------------------------------------------------------------------
   14. RESPONSIVE MEDIA QUERIES
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 260px;
  }

  .sm-only {
    display: inline-flex;
  }

  .app-sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }

  .app-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-2xl);
  }

  .sidebar-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    z-index: 35;
    display: none;
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .app-header {
    padding: 0 16px;
  }

  .app-main-content {
    padding: 16px;
  }

  .settings-grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-header {
    padding: 0 12px;
  }

  .header-left {
    gap: 10px;
    min-width: 0;
  }

  .header-titles {
    min-width: 0;
  }

  .header-page-title {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-page-subtitle {
    display: none;
  }

  .header-right {
    gap: 8px;
  }

  .header-account-pill .account-pill-email {
    display: none;
  }

  .header-account-pill {
    padding: 4px;
  }

  .popover-dropdown {
    max-width: calc(100vw - 24px);
    width: 280px;
    right: -8px;
  }

  .inbox-toolbar-card {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  .toolbar-search-col {
    max-width: 100%;
    width: 100%;
  }

  .toolbar-actions-col {
    width: 100%;
    justify-content: space-between;
  }

  .inbox-filter-select {
    flex-grow: 1;
  }

  /* Responsive email row */
  .email-row {
    padding: 12px 14px;
    gap: 10px;
    flex-wrap: wrap;
    position: relative;
  }

  .email-sender-col {
    width: auto;
    max-width: 140px;
    flex-grow: 1;
  }

  .email-content-col {
    width: 100%;
    order: 3;
    margin-top: 2px;
    flex-wrap: wrap;
    gap: 4px;
  }

  .email-snippet-text {
    display: none;
  }

  .email-meta-col {
    order: 2;
    margin-left: auto;
  }

  .email-row-actions {
    display: none !important;
  }

  .email-row:hover .email-time-text {
    display: block;
  }

  .email-list-footer {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    padding: 12px 14px;
  }

  /* Forwarding View */
  .destination-input-row {
    flex-direction: column;
    align-items: stretch;
  }

  .destination-actions-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .destination-actions-row .btn {
    width: 100%;
  }

  .dest-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* Reader View */
  .reader-card {
    padding: 16px;
    border-radius: var(--radius-lg);
  }

  .reader-header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 14px;
    margin-bottom: 14px;
  }

  .reader-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .subject-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .reader-subject-title {
    font-size: 1.125rem;
  }

  .reader-sender-box {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px;
    gap: 10px;
  }

  .sender-security-badges {
    flex-direction: row;
    align-items: center;
    width: 100%;
  }

  .reader-body-content {
    font-size: 0.875rem;
    line-height: 1.6;
  }

  .reader-footer-bar {
    padding-top: 16px;
  }

  .reader-footer-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .reader-footer-actions .btn {
    width: 100%;
  }

  /* Settings View */
  .settings-card {
    padding: 16px;
  }

  .theme-selector-grid {
    flex-direction: column;
  }

  .theme-option-card {
    max-width: 100%;
    width: 100%;
  }

  /* Modal */
  .modal-dialog {
    max-width: calc(100vw - 24px);
    margin: 12px;
  }

  .modal-header, .modal-body, .modal-footer {
    padding: 16px;
  }

  .modal-footer {
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
  }

  /* Toast */
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

/* ==========================================================================
   GLOBAL INITIALIZATION LOADING SCREEN
   ========================================================================== */

.app-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.app-loading-overlay.hidden {
  display: none !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px;
  max-width: 360px;
}

.loading-brand-icon {
  margin-bottom: 20px;
  animation: pulse-slow 2.4s ease-in-out infinite;
}

.loading-spinner-ring {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
  margin-bottom: 18px;
}

.loading-text-wrap .loading-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.loading-text-wrap .loading-subtext {
  font-size: 0.84375rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

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

@keyframes pulse-slow {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.04); opacity: 0.92; }
}

