/* ==========================================================================
   IDMBX - Modern Mailbox & Admin Dashboard Stylesheet
   Vanilla CSS Design System
   ========================================================================== */

:root {
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Dark Theme Palette (Default) */
  --bg-main: #0a0e1a;
  --bg-panel: rgba(18, 25, 43, 0.85);
  --bg-card: rgba(23, 32, 54, 0.7);
  --bg-hover: rgba(59, 130, 246, 0.12);
  --bg-active: rgba(59, 130, 246, 0.22);
  --bg-input: #0e1526;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.35);
  
  --accent: #6366f1;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;

  --shadow-sm: 0 2px 4px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.45);
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body.theme-light {
  --bg-main: #f4f6f9;
  --bg-panel: rgba(255, 255, 255, 0.9);
  --bg-card: #ffffff;
  --bg-hover: rgba(59, 130, 246, 0.08);
  --bg-active: rgba(59, 130, 246, 0.15);
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.06);
}

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

html, body {
  height: 100%;
  width: 100%;
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-glass);
}

/* Screens */
.view-screen {
  display: none;
  height: 100%;
  width: 100%;
}

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

/* Login View */
#login-view {
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, rgba(59, 130, 246, 0.15), transparent 60%), var(--bg-main);
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 36px 32px;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.logo-img-wrapper {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-logo-main {
  width: 56px;
  height: 56px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(59, 130, 246, 0.4));
  border-radius: var(--radius-md);
}

.brand-logo-nav {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(59, 130, 246, 0.3));
  border-radius: 6px;
  flex-shrink: 0;
}

.logo-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 8px 16px var(--primary-glow);
}

.logo-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
}

.gateway-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.status-dot.pulsing {
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================================================
   LOGIN PAGE ANIMATION — ambient background, entrance, success transition
   ========================================================================== */

#login-view {
  position: relative;
  overflow: hidden;
}

/* --- Ambient animated background (behind the card) --- */
.login-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Subtle moving grid for a "control room" feel */
.login-grid {
  position: absolute;
  inset: -50%;
  background-image:
    linear-gradient(rgba(59, 130, 246, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 70%);
  animation: grid-drift 40s linear infinite;
}

/* Soft drifting color blobs (aurora) */
.aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  will-change: transform;
}
.aurora-1 {
  width: 460px; height: 460px;
  top: -120px; left: -100px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.55), transparent 70%);
  animation: aurora-float-1 18s ease-in-out infinite;
}
.aurora-2 {
  width: 400px; height: 400px;
  bottom: -140px; right: -80px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.5), transparent 70%);
  animation: aurora-float-2 22s ease-in-out infinite;
}
.aurora-3 {
  width: 320px; height: 320px;
  top: 40%; left: 55%;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.35), transparent 70%);
  animation: aurora-float-3 26s ease-in-out infinite;
}

@keyframes grid-drift {
  from { transform: translate(0, 0); }
  to   { transform: translate(44px, 44px); }
}
@keyframes aurora-float-1 {
  0%,100% { transform: translate(0, 0) scale(1); }
  50%     { transform: translate(60px, 40px) scale(1.15); }
}
@keyframes aurora-float-2 {
  0%,100% { transform: translate(0, 0) scale(1); }
  50%     { transform: translate(-50px, -30px) scale(1.1); }
}
@keyframes aurora-float-3 {
  0%,100% { transform: translate(-50%, -50%) scale(1); opacity: 0.3; }
  50%     { transform: translate(-40%, -60%) scale(1.2); opacity: 0.5; }
}

/* --- Card sits above the background, enters with a gentle spring --- */
.login-card {
  position: relative;
  z-index: 1;
  animation: login-card-in 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes login-card-in {
  0%   { opacity: 0; transform: translateY(24px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Staggered entrance for the card's inner blocks */
.login-card > .logo-header,
.login-card > .gateway-badge,
.login-card > #login-form,
.login-card > .login-footer {
  animation: login-item-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.login-card > .logo-header   { animation-delay: 0.14s; }
.login-card > .gateway-badge { animation-delay: 0.22s; }
.login-card > #login-form    { animation-delay: 0.30s; }
.login-card > .login-footer  { animation-delay: 0.42s; }

@keyframes login-item-in {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Logo gets a soft floating breathe */
.login-card .brand-logo-main {
  animation: logo-breathe 5s ease-in-out infinite;
}
@keyframes logo-breathe {
  0%,100% { transform: translateY(0); filter: drop-shadow(0 4px 12px rgba(59, 130, 246, 0.4)); }
  50%     { transform: translateY(-4px); filter: drop-shadow(0 10px 20px rgba(59, 130, 246, 0.55)); }
}

/* Sign-in button: sheen sweep + submitting/loading states */
#btn-login {
  position: relative;
  overflow: hidden;
}
#btn-login::after {
  content: '';
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transform: skewX(-20deg);
  transition: none;
}
#btn-login:not(:disabled):hover::after {
  animation: btn-sheen 0.9s ease;
}
@keyframes btn-sheen {
  0%   { left: -120%; }
  100% { left: 140%; }
}

/* While submitting: button shows a spinner and hides its label/arrow */
#btn-login.is-loading { pointer-events: none; }
#btn-login.is-loading span,
#btn-login.is-loading svg { opacity: 0; }
#btn-login.is-loading::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Shake the card on a failed login for tactile feedback */
.login-card.login-error-shake {
  animation: login-shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes login-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}

/* --- Success overlay with an animated checkmark --- */
.login-success-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-radius: inherit;
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
.login-success-overlay.show {
  opacity: 1;
  visibility: visible;
}
.login-success-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  opacity: 0;
}
.login-success-overlay.show .login-success-text {
  animation: success-text-in 0.4s ease 0.5s both;
}
@keyframes success-text-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.success-check { display: block; }
.success-check-circle {
  stroke: var(--success);
  stroke-width: 3;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
}
.success-check-mark {
  stroke: var(--success);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
}
.login-success-overlay.show .success-check-circle {
  animation: draw-circle 0.5s ease-out forwards;
}
.login-success-overlay.show .success-check-mark {
  animation: draw-mark 0.35s ease-out 0.42s forwards;
}
@keyframes draw-circle { to { stroke-dashoffset: 0; } }
@keyframes draw-mark   { to { stroke-dashoffset: 0; } }

/* When login succeeds, ease the whole login view out */
#login-view.login-leaving {
  animation: login-view-out 0.55s ease forwards;
}
@keyframes login-view-out {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.04); }
}

/* Fade the app in when it appears */
#main-view.app-entering {
  animation: app-fade-in 0.5s ease both;
}
@keyframes app-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Respect users who prefer reduced motion: keep it calm and instant */
@media (prefers-reduced-motion: reduce) {
  .login-grid,
  .aurora,
  .login-card .brand-logo-main,
  .login-card,
  .login-card > .logo-header,
  .login-card > .gateway-badge,
  .login-card > #login-form,
  .login-card > .login-footer,
  #login-view.login-leaving,
  #main-view.app-entering {
    animation: none !important;
  }
  #btn-login.is-loading::before { animation: btn-spin 0.7s linear infinite; } /* keep spinner only */
  .login-success-overlay.show .success-check-circle,
  .login-success-overlay.show .success-check-mark { animation: none; stroke-dashoffset: 0; }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.compact-label {
  width: 60px;
  font-weight: 500;
  color: var(--text-muted);
}

.form-checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
}

.field-hint {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  outline: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--primary-glow);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--text-dim);
}

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

.btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

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

.btn-icon-sm {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-icon-sm:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 12px;
}

.btn-compose {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  letter-spacing: 0.3px;
}

.alert-box {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
}

.alert-box.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.login-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
}

/* Navbar */
.navbar {
  height: 60px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  z-index: 50;
}

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

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

.brand-icon {
  color: var(--primary);
}

.brand-name {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.3px;
}

.nav-center {
  flex: 1;
  max-width: 540px;
  margin: 0 24px;
}

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

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

.search-input-wrapper input {
  padding-left: 38px;
  padding-right: 32px;
  height: 38px;
  border-radius: 20px;
  background: var(--bg-input);
}

.search-input-wrapper .btn-icon-sm {
  position: absolute;
  right: 8px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.view-switchers {
  display: flex;
  background: var(--bg-input);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.btn-tab {
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
}

.btn-tab.active {
  background: var(--primary);
  color: #ffffff;
}

.user-profile-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--border-color);
}

.user-avatar, .sender-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-display-name {
  font-weight: 600;
  font-size: 13px;
}

.user-display-email {
  font-size: 11px;
  color: var(--text-dim);
}

/* Layout Body */
.layout-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.app-section {
  display: none;
  width: 100%;
  height: 100%;
}

.app-section.active {
  display: flex;
}

/* Webmail & App Sidebar */
.sidebar {
  width: 250px;
  min-width: 250px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease,
              border-color 0.2s ease;
  white-space: nowrap;
}

/* Collapsed Sidebar: Icon-Only Rail */
.sidebar.collapsed {
  width: 68px !important;
  min-width: 68px !important;
  max-width: 68px !important;
  padding: 14px 6px !important;
  overflow-x: hidden !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  visibility: visible !important;
  align-items: center;
}

.sidebar.collapsed .sidebar-top {
  margin-bottom: 14px;
  width: 100%;
  display: flex;
  justify-content: center;
}

.sidebar.collapsed .btn-compose {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0 !important;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
  flex-shrink: 0;
}

.sidebar.collapsed .btn-compose span {
  display: none !important;
}

.sidebar.collapsed .btn-compose svg {
  margin: 0 !important;
  width: 20px;
  height: 20px;
}

.sidebar.collapsed .sidebar-menu {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar.collapsed .menu-label,
.sidebar.collapsed .menu-label-row,
.sidebar.collapsed #admin-sidebar-badge,
.sidebar.collapsed .no-custom-folders-item {
  display: none !important;
}

.sidebar.collapsed #custom-folder-list {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  width: 100%;
}

.sidebar.collapsed .nav-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.sidebar.collapsed .nav-item {
  width: 44px;
  height: 44px;
  padding: 0 !important;
  margin: 0 auto;
  justify-content: center;
  align-items: center;
  border-radius: 10px;
  position: relative;
  box-shadow: none !important;
}

.sidebar.collapsed .nav-item.active {
  background: var(--bg-active);
  box-shadow: none !important;
}

.sidebar.collapsed .nav-item.active .nav-icon-box {
  background: rgba(59, 130, 246, 0.2);
}

.sidebar.collapsed .nav-text-group,
.sidebar.collapsed .folder-total-count,
.sidebar.collapsed .folder-action-btn,
.sidebar.collapsed .notes-tags-list,
.sidebar.collapsed .calendar-sidebar-events,
.sidebar.collapsed .files-category-list,
.sidebar.collapsed .task-progress-summary,
.sidebar.collapsed .badge:not(.badge-unread) {
  display: none !important;
}

.sidebar.collapsed .nav-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar.collapsed .nav-item .badge-unread {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.sidebar.collapsed .sidebar-bottom {
  display: none !important;
}

#btn-toggle-sidebar.active {
  background: var(--bg-active);
  color: var(--primary);
}

.sidebar-top {
  margin-bottom: 20px;
}

.menu-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  padding: 0 10px 8px;
  font-weight: 700;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  font-size: 13px;
  position: relative;
}

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

.nav-item.active {
  background: var(--bg-active);
  color: var(--primary);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary);
}

.nav-icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}

.nav-text-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  text-align: left;
  overflow: hidden;
}

.nav-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-main);
  line-height: 1.2;
}

.nav-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.2;
}

.folder-total-count {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
  font-weight: 500;
}

.nav-item .badge {
  margin-left: auto;
}

.badge {
  background: var(--bg-hover);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-unread {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 0 8px var(--primary-glow);
}

.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.quota-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quota-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
}

.quota-bar-wrapper {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.quota-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.4s ease;
}

/* Mail List Pane */
.mail-list-pane {
  width: 380px;
  border-right: 1px solid var(--border-color);
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.pane-header {
  height: 56px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

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

.header-left h2 {
  font-size: 16px;
  font-weight: 700;
}

.mail-list-container {
  flex: 1;
  overflow-y: auto;
}

.mail-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  gap: 12px;
  position: relative;
}

.mail-item:hover {
  background: var(--bg-hover);
}

.mail-item.selected {
  background: var(--bg-active);
  border-left: 3px solid var(--primary);
}

.mail-item.unread {
  background: rgba(59, 130, 246, 0.05);
}

.mail-item.unread .mail-sender,
.mail-item.unread .mail-subject-row {
  font-weight: 700;
  color: var(--text-main);
}

.mail-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mail-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mail-sender {
  font-size: 13px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.mail-date {
  font-size: 11px;
  color: var(--text-dim);
}

.mail-subject-row {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-snippet {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mail Detail Pane */
.mail-detail-pane {
  flex: 1;
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.empty-state {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  gap: 12px;
  padding: 40px;
  text-align: center;
}

.empty-state.active {
  display: flex;
}

.detail-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-toolbar {
  height: 52px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

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

.mail-header-card {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}

.mail-subject {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 14px;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sender-info {
  flex: 1;
}

.from-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.email-subtext {
  color: var(--text-dim);
  font-size: 12px;
}

.to-line {
  font-size: 12px;
  color: var(--text-muted);
}

.date-badge {
  font-size: 12px;
  color: var(--text-dim);
}

.attachments-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
}

.attach-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.attach-pills {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.attachment-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  gap: 10px;
  transition: var(--transition);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.attachment-item-card:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.attachment-item-card.threat-detected {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

.att-card-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.att-card-icon {
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.att-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.att-card-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.att-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

.meta-dot {
  opacity: 0.5;
}

.att-security-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
}

.att-security-badge.badge-clean {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.att-security-badge.badge-virus {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  animation: pulse-danger 1.5s infinite;
}

@keyframes pulse-danger {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

.att-security-badge.badge-scanned {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.att-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btn-att-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-panel);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.btn-att-action:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.btn-att-download:hover {
  background: #10b981;
  border-color: #10b981;
  color: #ffffff;
}

.mail-body-container {
  flex: 1;
  overflow-y: auto;
  position: relative;
  background: var(--bg-main);
  padding: 16px 20px;
}

.mail-paper-canvas {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  min-height: 250px;
}

.mail-paper-canvas.canvas-light {
  background: #ffffff !important;
  color: #1e293b !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
}

.mail-paper-canvas.canvas-light .text-body-view {
  color: #0f172a !important;
}

.mail-paper-canvas.canvas-light .text-body-view blockquote,
.mail-paper-canvas.canvas-light .quote-line {
  color: #475569 !important;
  background: #f8fafc !important;
  border-left-color: #3b82f6 !important;
}

#detail-body-frame {
  width: 100%;
  min-height: 250px;
  border: none;
  background: transparent;
  display: block;
}

.text-body-view {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-main);
  word-break: break-word;
}

.text-body-view blockquote,
.quote-line {
  border-left: 3px solid var(--primary);
  padding-left: 14px;
  margin: 12px 0;
  color: var(--text-muted);
  font-style: normal;
  background: rgba(59, 130, 246, 0.06);
  padding-top: 6px;
  padding-bottom: 6px;
  border-radius: 0 6px 6px 0;
}

/* WYSIWYG Editor */
.wysiwyg-wrapper {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  overflow: hidden;
  transition: var(--transition);
}

.wysiwyg-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.wysiwyg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  user-select: none;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 6px;
  margin-right: 6px;
  border-right: 1px solid var(--border-color);
}

.toolbar-group:last-child {
  border-right: none;
  padding-right: 0;
  margin-right: 0;
}

.tb-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
}

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

.tb-btn:active {
  background: var(--bg-active);
  color: var(--primary);
}

.tb-select {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  height: 30px;
  outline: none;
  cursor: pointer;
}

.wysiwyg-editor {
  min-height: 220px;
  max-height: 480px;
  overflow-y: auto;
  padding: 16px;
  outline: none;
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.6;
}

.wysiwyg-editor[placeholder]:empty:before {
  content: attr(placeholder);
  color: var(--text-dim);
  pointer-events: none;
}

.wysiwyg-editor blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 12px;
  margin: 10px 0;
  color: var(--text-dim);
}

.wysiwyg-editor a {
  color: var(--primary);
  text-decoration: underline;
}

.wysiwyg-editor ul, .wysiwyg-editor ol {
  padding-left: 24px;
  margin: 8px 0;
}

.raw-box {
  background: #000000;
  color: #38bdf8;
  padding: 16px;
  font-family: monospace;
  font-size: 12px;
  max-height: 250px;
  overflow-y: auto;
  border-bottom: 1px solid var(--border-color);
}

/* Admin Dashboard Pane */
.admin-sidebar {
  width: 250px;
  min-width: 250px;
}

.admin-content-pane {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
}

.admin-tab-content {
  display: none;
}

.admin-tab-content.active {
  display: block;
}

.page-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title-bar h2 {
  font-size: 22px;
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.stat-footer {
  font-size: 12px;
  color: var(--text-dim);
}

.admin-sections-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.card {
  padding: 22px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card h3 {
  font-size: 16px;
  font-weight: 600;
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.table-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.data-table th {
  padding: 12px 16px;
  background: var(--bg-card);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

.data-table tr:hover td {
  background: var(--bg-hover);
}

.result-box {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  font-size: 13px;
}

.ssl-layout-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
}

.ssl-info-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.info-row .label {
  color: var(--text-muted);
  font-size: 13px;
}

.info-row .value {
  font-weight: 600;
}

.log-box {
  background: #000000;
  color: #10b981;
  padding: 14px;
  border-radius: var(--radius-md);
  font-family: monospace;
  font-size: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.architecture-flow {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 24px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  margin: 10px 0;
}

.flow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.flow-icon {
  font-size: 32px;
  margin-bottom: 4px;
}

.flow-arrow {
  font-size: 24px;
  color: var(--primary);
}

.idmg-details-box {
  background: var(--bg-input);
  padding: 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
}

.idmg-details-box ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-slide-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.modal-lg {
  max-width: 760px;
}

@keyframes modal-slide-in {
  from { transform: translateY(20px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.compose-editor-wrapper textarea {
  resize: vertical;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
}

/* ==========================================================================
   Gmail-Style Floating / Docked Compose Window
   ========================================================================== */
.compose-window {
  position: fixed;
  bottom: 0;
  right: 24px;
  width: 580px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 50px);
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 2px 10px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  z-index: 90;
  transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              height 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.2s ease,
              border-radius 0.2s ease;
  overflow: hidden;
}

body.theme-light .compose-window {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-bottom: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
}

.compose-window.hidden {
  display: none !important;
}

/* Header */
.compose-header {
  padding: 10px 14px;
  background: #1e293b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  height: 42px;
  transition: background 0.2s ease;
}

body.theme-light .compose-header {
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
}

.compose-header:hover {
  background: #243248;
}

body.theme-light .compose-header:hover {
  background: #e2e8f0;
}

.compose-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
}

.compose-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.compose-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
  flex-shrink: 0;
}

.compose-ctrl-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.compose-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}

body.theme-light .compose-ctrl-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-main);
}

/* Minimized State */
.compose-window.minimized {
  height: 42px !important;
  width: 280px !important;
  max-width: calc(100vw - 32px);
  border-radius: 10px 10px 0 0 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.compose-window.minimized #compose-form {
  display: none !important;
}

.compose-window.minimized .compose-header {
  border-bottom: none;
}

/* Maximized State */
.compose-window.maximized {
  top: 50% !important;
  left: 50% !important;
  bottom: auto !important;
  right: auto !important;
  transform: translate(-50%, -50%) !important;
  width: 90vw !important;
  max-width: 980px !important;
  height: 86vh !important;
  max-height: 86vh !important;
  border-radius: 14px !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.7) !important;
  z-index: 150 !important;
}

body.theme-light .compose-window.maximized {
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22) !important;
}

/* Form structure within compose window */
.compose-window #compose-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.compose-window #compose-form .modal-body {
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.compose-window #compose-form .modal-footer,
.compose-modal-footer {
  padding: 10px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 10px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.compose-from-select {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.compose-from-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

body.theme-light .compose-from-select {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}

body.theme-light .compose-from-select option {
  background: #ffffff;
  color: #0f172a;
}

.compose-footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.compose-send-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff !important;
  border: none;
  border-radius: 20px;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
  transition: all 0.2s ease;
  white-space: nowrap;
  line-height: 1;
}

.compose-send-btn:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

.compose-send-btn:active {
  transform: translateY(0);
}

.compose-footer-sep {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 4px;
}

.compose-footer-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

.compose-footer-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-color);
}

.compose-footer-icon-btn.compose-discard-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25);
}

.compose-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.compose-draft-status {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.compose-save-draft-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1;
}

.compose-save-draft-btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
}

body.theme-light .compose-send-btn {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff !important;
}

body.theme-light .compose-save-draft-btn {
  border-color: #cbd5e1;
  color: #334155;
  background: #ffffff;
}

body.theme-light .compose-save-draft-btn:hover {
  background: #f8fafc;
  border-color: var(--primary);
  color: var(--primary);
}

body.theme-light .compose-footer-icon-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.compose-window #compose-form .wysiwyg-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 180px;
}

.compose-window.maximized #compose-form .wysiwyg-wrapper {
  flex: 1;
}

.compose-window.maximized #compose-form .wysiwyg-editor {
  min-height: 300px;
  max-height: none;
  flex: 1;
}

.compose-window:not(.maximized) #compose-form .wysiwyg-editor {
  min-height: 160px;
  max-height: 280px;
  flex: 1;
}

@media (max-width: 768px) {
  .compose-window {
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;          /* 100% avoids the 100vw scrollbar overflow that forced zoom-out */
    max-width: 100% !important;
    bottom: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
  }
  .compose-window.minimized {
    right: 12px !important;
    left: auto !important;
    width: 220px !important;
    max-width: calc(100% - 24px) !important;
    height: 42px !important;
    border-radius: 10px 10px 0 0 !important;
  }
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1200;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s ease;
}

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

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-dim);
}

/* Spam Alert Banner & Actions */
.spam-alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  margin: 16px 24px 0 24px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, rgba(245, 158, 11, 0.08) 100%);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-lg);
  color: var(--text-main);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.08);
  animation: banner-slide-down 0.25s ease-out;
}

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

.spam-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.spam-banner-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  flex-shrink: 0;
}

.spam-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.spam-banner-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #f87171;
}

.spam-banner-sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.btn-spam-to-inbox {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff !important;
  font-weight: 600;
  border: none;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  white-space: nowrap;
  flex-shrink: 0;
  transition: var(--transition);
}

.btn-spam-to-inbox:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
}

.btn-not-spam {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981 !important;
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-not-spam:hover {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #10b981 !important;
}

/* ==========================================================================
   CALENDAR & MEETING INVITATION STYLES
   ========================================================================== */

/* 1. Meeting Card inside Email Reader */
.calendar-invite-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  padding: 18px 22px;
  margin: 16px 24px 0 24px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(139, 92, 246, 0.08) 100%);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.08);
  animation: banner-slide-down 0.25s ease-out;
}

.cal-card-left {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex: 1;
  min-width: 280px;
}

.cal-date-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 58px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.cal-badge-month {
  width: 100%;
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  padding: 2px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cal-badge-day {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.3;
}

.cal-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.cal-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-event-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.cal-rsvp-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.cal-rsvp-badge.badge-accepted {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.cal-rsvp-badge.badge-tentative {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.cal-rsvp-badge.badge-declined {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.cal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.cal-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.cal-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.cal-meta-item svg {
  color: var(--primary);
  flex-shrink: 0;
}

.cal-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.btn-meet-join {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff !important;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transition: var(--transition);
  text-decoration: none;
}

.btn-meet-join:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.5);
  color: #ffffff !important;
}

.rsvp-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rsvp-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.rsvp-btn-group {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.btn-rsvp {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border-right: 1px solid var(--border-color);
}

.btn-rsvp:last-child {
  border-right: none;
}

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

.btn-rsvp#btn-rsvp-yes.active {
  background: #10b981;
  color: #ffffff;
}

.btn-rsvp#btn-rsvp-maybe.active {
  background: #3b82f6;
  color: #ffffff;
}

.btn-rsvp#btn-rsvp-no.active {
  background: #ef4444;
  color: #ffffff;
}

/* 2. Compose Modal Meeting Scheduler Section */
.compose-calendar-section {
  margin: 2px 0 6px 0;
}

.compose-cal-toggle-row {
  display: flex;
  align-items: center;
}

.btn-cal-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 4px 11px;
  border-radius: 16px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-cal-toggle:hover {
  background: var(--bg-hover);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-cal-toggle.active {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  border-color: var(--primary);
}

.compose-meeting-box {
  margin-top: 10px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-with-action {
  display: flex;
  gap: 8px;
}

.input-with-action input {
  flex: 1;
}

/* 3. Calendar View Layout */
.calendar-sidebar {
  width: 280px;
}

.calendar-sidebar-events {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 12px;
  overflow-y: auto;
  max-height: calc(100vh - 200px);
}

.sidebar-event-card {
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-event-card:hover {
  transform: translateX(3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.sidebar-event-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-event-date {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
}

.sidebar-event-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-event-sub {
  font-size: 11.5px;
  color: var(--text-dim);
}

.btn-event-quick-join {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: #3b82f6 !important;
  background: rgba(59, 130, 246, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
  text-decoration: none;
}

.btn-event-quick-join:hover {
  background: #3b82f6;
  color: #ffffff !important;
}

.empty-sidebar-events {
  padding: 20px 10px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

.calendar-main-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  overflow: hidden;
  background: var(--bg-main);
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}

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

.cal-nav-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.calendar-month-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.calendar-view-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 24px;
  overflow-y: auto;
}

.calendar-days-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.calendar-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(110px, 1fr);
  gap: 1px;
  background: var(--border-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 10px;
}

.calendar-day-cell {
  background: var(--bg-card);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 110px;
  cursor: pointer;
  transition: var(--transition);
}

.calendar-day-cell:hover {
  background: var(--bg-hover);
}

.calendar-day-cell.other-month {
  background: var(--bg-main);
  opacity: 0.45;
}

.calendar-day-cell.today {
  background: rgba(59, 130, 246, 0.06);
}

.calendar-day-cell.today .day-number {
  background: var(--primary);
  color: #ffffff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  align-self: flex-start;
}

.cell-events-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 90px;
}

.calendar-event-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  background: rgba(59, 130, 246, 0.15);
  border-left: 3px solid #3b82f6;
  border-radius: 3px;
  font-size: 11px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: var(--transition);
}

.calendar-event-pill:hover {
  background: rgba(59, 130, 246, 0.3);
  transform: translateY(-1px);
}

.calendar-event-pill.declined {
  opacity: 0.45;
  text-decoration: line-through;
  border-left-color: #ef4444;
}

.pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #3b82f6;
  flex-shrink: 0;
}

.pill-time {
  font-weight: 600;
  color: var(--primary);
  font-size: 10px;
  flex-shrink: 0;
}

.pill-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   PERSONAL NOTES STYLES
   ========================================================================== */

.notes-sidebar {
  width: 260px;
}

.notes-tags-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
}

.tag-badge-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

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

.tag-badge-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  font-weight: 600;
}

.tag-badge-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.badge-sub {
  font-size: 11px;
  background: var(--bg-input);
  padding: 1px 6px;
  border-radius: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
  margin-left: 8px;
}

.no-tags-hint {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 8px;
}

.notes-main-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  overflow: hidden;
  background: var(--bg-main);
}

.notes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  gap: 16px;
}

.notes-search-wrapper {
  position: relative;
  flex: 1;
  max-width: 460px;
}

.notes-search-wrapper input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 13.5px;
  transition: var(--transition);
}

.notes-search-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.notes-search-wrapper .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.notes-body-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.quick-note-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  color: var(--text-dim);
}

.quick-note-box:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.12);
  transform: translateY(-1px);
  color: var(--primary);
}

.quick-note-placeholder {
  font-size: 14px;
  color: var(--text-dim);
}

.notes-group-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.notes-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.notes-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.note-card {
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  min-height: 140px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.note-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

/* Note Color Variants */
.note-card.note-yellow {
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.12) 0%, rgba(245, 158, 11, 0.04) 100%);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.note-card.note-blue {
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.12) 0%, rgba(59, 130, 246, 0.04) 100%);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.note-card.note-green {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.12) 0%, rgba(16, 185, 129, 0.04) 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.note-card.note-purple {
  background: linear-gradient(145deg, rgba(139, 92, 246, 0.12) 0%, rgba(139, 92, 246, 0.04) 100%);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.note-card.note-rose {
  background: linear-gradient(145deg, rgba(244, 63, 94, 0.12) 0%, rgba(244, 63, 94, 0.04) 100%);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.note-card.note-dark {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

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

.note-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.4;
  margin: 0;
  word-break: break-word;
}

.btn-pin-note {
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  opacity: 0.6;
}

.note-card:hover .btn-pin-note,
.btn-pin-note.pinned {
  opacity: 1;
}

.btn-pin-note.pinned {
  color: var(--primary);
}

.btn-pin-note:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

.note-card-content {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
  word-break: break-word;
  max-height: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* The note content is rendered markdown (HTML), not raw text, so we must NOT
   use white-space: pre-wrap here — the newlines the renderer inserts between
   block tags would otherwise show up as large blank gaps. Also trim the outer
   margins of the first/last block so the card stays tight. */
.note-card-content.md-content > :first-child { margin-top: 0; }
.note-card-content.md-content > :last-child { margin-bottom: 0; }
.note-card-content.md-content .md-h { margin-top: 6px; }
.note-card-content.md-content .md-ul,
.note-card-content.md-content .md-ol { margin: 2px 0 6px; }
.note-card-content.md-content .md-pre,
.note-card-content.md-content .md-quote { margin: 4px 0 6px; }
.note-card-content.md-content .md-hr { margin: 6px 0; }

.note-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.note-tag-pill {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}

.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  font-size: 11px;
  color: var(--text-dim);
}

.btn-icon-xs {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 3px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-xs:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Modal Inputs for Notes */
.note-title-input {
  font-size: 18px !important;
  font-weight: 700 !important;
  border: none !important;
  border-bottom: 1px solid var(--border-color) !important;
  border-radius: 0 !important;
  padding: 8px 0 !important;
  background: transparent !important;
}

.note-title-input:focus {
  border-bottom-color: var(--primary) !important;
  box-shadow: none !important;
}

.note-content-input {
  font-size: 14px !important;
  line-height: 1.6 !important;
  border: none !important;
  background: transparent !important;
  padding: 8px 0 !important;
  resize: vertical;
}

.note-content-input:focus {
  outline: none !important;
}

.note-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.note-color-picker {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-picker-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.color-swatches {
  display: flex;
  gap: 8px;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--primary);
  transform: scale(1.15);
}

.swatch-yellow { background: #f59e0b; }
.swatch-blue   { background: #3b82f6; }
.swatch-green  { background: #10b981; }
.swatch-purple { background: #8b5cf6; }
.swatch-rose   { background: #f43f5e; }
.swatch-dark   { background: #334155; }

/* Antivirus Alert Banner */
.virus-alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  margin: 16px 24px 0 24px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.18) 0%, rgba(185, 28, 28, 0.12) 100%);
  border: 1px solid rgba(239, 68, 68, 0.5);
  border-radius: var(--radius-lg);
  color: var(--text-main);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.15);
  animation: banner-slide-down 0.25s ease-out;
}

.virus-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.virus-banner-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.25);
  color: #ef4444;
  flex-shrink: 0;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.virus-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.virus-banner-title {
  font-size: 14px;
  font-weight: 700;
  color: #f87171;
  letter-spacing: -0.2px;
}

.virus-banner-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Document & Image Preview Modal */
.modal-preview-card {
  width: 95vw !important;
  max-width: 1100px !important;
  height: 88vh !important;
  max-height: 88vh !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 1px solid var(--border-color);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-panel);
  flex-shrink: 0;
  gap: 16px;
}

.preview-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.preview-file-icon {
  font-size: 26px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.preview-title-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.preview-filename {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.preview-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.preview-divider {
  opacity: 0.5;
}

.preview-security-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.preview-security-badge.badge-clean {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.preview-security-badge.badge-virus {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.preview-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.preview-zoom-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  padding: 3px 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.preview-zoom-text {
  font-size: 11.5px;
  font-weight: 600;
  min-width: 44px;
  text-align: center;
  color: var(--text-muted);
}

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

.preview-body {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  padding: 0 !important;
}

/* Image Viewer */
.preview-img-wrapper {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 24px;
}

.preview-img-element {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease-out;
}

/* PDF Viewer */
.preview-pdf-wrapper {
  flex: 1;
  width: 100%;
  height: 100%;
}

.preview-pdf-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

/* Text / Code Viewer */
.preview-text-wrapper {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 20px;
  background: var(--bg-canvas);
}

.preview-text-element {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* Office & Archive Info Card */
.preview-office-wrapper {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.preview-office-card {
  max-width: 540px;
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.office-card-icon {
  font-size: 54px;
  margin-bottom: 16px;
}

.office-card-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
  word-break: break-all;
}

.office-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.office-meta-table {
  width: 100%;
  background: var(--bg-input);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 14px 18px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.meta-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.meta-label {
  color: var(--text-dim);
  font-weight: 500;
}

.meta-value {
  color: var(--text-main);
  font-weight: 600;
}

.office-actions {
  width: 100%;
}

.office-actions .btn {
  width: 100%;
  justify-content: center;
  padding: 12px 20px;
}

/* Virus Warning Inside Modal */
.preview-virus-alert {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
}

.virus-alert-card {
  max-width: 460px;
  width: 100%;
  background: rgba(239, 68, 68, 0.1);
  border: 2px solid #ef4444;
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(239, 68, 68, 0.25);
}

.virus-alert-icon {
  font-size: 52px;
  margin-bottom: 12px;
}

.virus-alert-card h3 {
  font-size: 18px;
  color: #f87171;
  font-weight: 700;
  margin-bottom: 10px;
}

.virus-alert-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 20px;
}

.virus-alert-buttons {
  display: flex;
  justify-content: center;
}

/* ==========================================================================
   Professional Overview & Health Dashboard Styles
   ========================================================================== */
.overview-section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px 0;
}

.overview-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.overview-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.overview-grid-roles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.overview-grid-objects {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

@media (max-width: 1200px) {
  .overview-grid-4, .overview-grid-roles {
    grid-template-columns: repeat(2, 1fr);
  }
  .overview-grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .overview-grid-4, .overview-grid-3, .overview-grid-roles, .overview-grid-objects {
    grid-template-columns: 1fr;
  }
}

.metric-card-pro {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.metric-card-pro:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.metric-card-pro::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--card-accent, #3b82f6);
  opacity: 0.8;
}

.metric-header-pro {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-title-pro {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.metric-sub-pro {
  font-size: 11px;
  color: var(--text-muted);
}

.metric-icon-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.metric-value-pro {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.metric-progress-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.metric-progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.metric-footer-pro {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.role-card-pro {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.role-card-pro:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.18);
}

.role-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.role-info-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.role-info-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.role-info-count {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.role-info-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.spec-list-pro {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.spec-item-pro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.spec-item-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.spec-item-icon-box {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.spec-item-value {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  font-family: var(--font-mono, monospace);
}

.storage-user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.storage-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1e293b;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #60a5fa;
  flex-shrink: 0;
  overflow: hidden;
}

.storage-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Username suggestions chips */
.username-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-family: monospace;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.username-chip:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
  color: #ffffff;
  transform: translateY(-1px);
}
.username-chip:active {
  transform: translateY(0);
}

/* ==========================================================================
   NEW MAIL FEATURES: Star, Bulk Selection, Custom Folders, Archive, Drafts
   ========================================================================== */

/* Star Button */
.btn-star {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  transition: transform 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 4px;
}
.btn-star:hover {
  transform: scale(1.2);
  color: #f59e0b;
}
.btn-star.starred {
  color: #f59e0b;
}

/* Checkbox & Star in mail item */
.mail-select-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.mail-checkbox {
  cursor: pointer;
  width: 15px;
  height: 15px;
  accent-color: #3b82f6;
  border-radius: 3px;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}
.mail-item:hover .mail-checkbox,
.mail-checkbox:checked {
  opacity: 1;
}

/* Mail Item Hover Actions */
.mail-hover-actions {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  gap: 4px;
  background: var(--bg-panel);
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  z-index: 5;
}
.mail-item:hover .mail-hover-actions {
  display: flex;
}
.btn-hover-action {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-hover-action:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

/* Bulk Toolbar */
.mail-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0,0,0,0.12);
  min-height: 40px;
}
.btn-bulk-action {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.btn-bulk-action:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: rgba(255,255,255,0.25);
}

/* Custom Folders in Sidebar */
.custom-folder-item {
  position: relative;
}
.folder-action-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  margin-left: auto;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.nav-item:hover .folder-action-btn {
  opacity: 1;
}
.folder-action-btn:hover {
  color: var(--text-main);
  background: rgba(255,255,255,0.12);
}

/* Banners for Archive & Draft */
.archive-alert-banner {
  background: rgba(139, 92, 246, 0.1);
  border-bottom: 1px solid rgba(139, 92, 246, 0.25);
  padding: 12px 20px;
}
.draft-alert-banner {
  background: rgba(245, 158, 11, 0.1);
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
  padding: 12px 20px;
}
.folder-select-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13.5px;
  font-weight: 500;
}
.folder-select-item:hover {
  background: var(--bg-hover);
  border-color: #3b82f6;
  color: #60a5fa;
}

/* ==========================================================================
   File Manager & Attachment Sharing System
   ========================================================================== */
#section-files {
  display: none;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

#section-files.active {
  display: flex !important;
}

.files-sidebar {
  width: 260px;
  min-width: 260px;
}

.files-category-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.cat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}

.cat-chip:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.cat-chip.active {
  background: var(--bg-active);
  color: var(--primary);
  font-weight: 600;
}

.files-storage-meter {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
}

.storage-meter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.storage-meter-header strong {
  color: var(--text-main);
}

.storage-meter-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.storage-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.storage-meter-footer {
  font-size: 11px;
  color: var(--text-dim);
}

/* Files Main Pane */
.files-main-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  overflow: hidden;
}

.files-toolbar {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-panel);
}

.files-search-wrapper {
  position: relative;
  flex: 1;
  max-width: 480px;
}

.files-search-wrapper input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

.files-search-wrapper input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.files-search-wrapper .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

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

.btn-group-sm {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.btn-group-sm .btn {
  border: none;
  border-radius: 0;
  padding: 6px 10px;
}

.btn-group-sm .btn.active {
  background: var(--primary);
  color: #fff;
}

/* Dropzone & Container */
.files-dropzone-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  position: relative;
  transition: background 0.2s ease;
}

.files-dropzone-container.dragover {
  background: rgba(59, 130, 246, 0.08);
  border: 2px dashed #3b82f6;
}

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

.files-list-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* File Card (Grid Mode) */
.file-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  position: relative;
}

.file-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(59, 130, 246, 0.4);
}

.file-card-preview {
  height: 120px;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.file-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.file-card:hover .file-card-preview img {
  transform: scale(1.05);
}

.file-card-preview-icon {
  font-size: 42px;
  user-select: none;
}

.file-card-source-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 12px;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  color: #93c5fd;
  font-weight: 500;
}

.file-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.file-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.file-card-meta {
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.file-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.file-badge {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.file-badge-private {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
}

.file-badge-shared {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.file-badge-public {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.file-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
  margin-top: auto;
}

.file-card-actions .btn-icon-sm {
  width: 28px;
  height: 28px;
}

/* File Row (List Mode) */
.file-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.file-row:hover {
  border-color: rgba(59, 130, 246, 0.4);
  background: var(--bg-hover);
}

.file-row-icon {
  font-size: 22px;
  width: 32px;
  text-align: center;
}

.file-row-name {
  flex: 2;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.file-row-owner {
  flex: 1;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.file-row-size {
  width: 80px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
}

.file-row-date {
  width: 110px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
}

.file-row-badges {
  width: 120px;
  display: flex;
  justify-content: center;
}

.file-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Sharing Modal Components */
.file-share-info-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  margin-bottom: 14px;
}

.file-share-info-card .file-icon-box {
  font-size: 28px;
}

.share-users-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.share-user-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

.share-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 12px;
  font-size: 11.5px;
  color: #60a5fa;
  cursor: pointer;
  transition: all 0.15s ease;
}

.share-user-chip:hover {
  background: rgba(59, 130, 246, 0.25);
}

/* File Picker Grid in Compose */
.file-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.file-picker-card {
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.15s ease;
}

.file-picker-card:hover {
  border-color: #3b82f6;
  background: var(--bg-hover);
}

.file-picker-card.selected {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.18);
  box-shadow: 0 0 0 2px #3b82f6;
}

.file-picker-card-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.file-picker-card-meta {
  font-size: 11px;
  color: var(--text-dim);
}

/* Save to Files button on incoming mail attachments */
.btn-save-attachment-to-files {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-save-attachment-to-files:hover {
  border-color: #3b82f6;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.1);
}


/* ==========================================================================
   TO-DO LIST / TASKS
   ========================================================================== */

/* Shared progress bar (also reused by task cards & summary) */
.progress-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Sidebar overall progress summary */
.task-progress-summary {
  padding: 14px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-progress-ring-wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.task-progress-percent {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
}

.task-progress-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Toolbar action cluster (view/priority selects + report buttons).
   Kept on one tidy row on desktop; wraps cleanly on smaller screens. */
.notes-toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

/* Professional select control with a custom chevron so it looks consistent
   across browsers and matches the input/button height in the toolbar. */
.task-filter-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  height: 36px;
  width: auto;
  background-color: var(--bg-input);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 32px 0 12px;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 34px;
  cursor: pointer;
  transition: var(--transition);
}

.task-filter-select:hover {
  border-color: var(--border-focus);
  background-color: var(--bg-hover);
}

.task-filter-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Tasks list */
.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0;
}

.task-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--text-dim);
  transition: var(--transition);
}

.task-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.task-card.status-todo { border-left-color: var(--text-dim); }
.task-card.status-progress { border-left-color: var(--warning); }
.task-card.status-done { border-left-color: var(--success); }

.task-card.is-done .task-card-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-card-check {
  padding-top: 2px;
}

.task-card-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--success);
}

.task-card-body {
  flex: 1;
  cursor: pointer;
  min-width: 0;
}

.task-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.task-card-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-word;
}

.task-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 4px 0 10px;
  word-break: break-word;
}

/* The description is rendered markdown (HTML), not raw text, so we must NOT
   use white-space: pre-wrap here — the newlines the renderer inserts between
   block tags would otherwise show up as large blank gaps. Also trim the outer
   margins of the first/last block so the card stays tight. */
.task-card-desc.md-content > :first-child { margin-top: 0; }
.task-card-desc.md-content > :last-child { margin-bottom: 0; }
.task-card-desc.md-content .md-h { margin-top: 6px; }
.task-card-desc.md-content .md-ul,
.task-card-desc.md-content .md-ol { margin: 2px 0 6px; }
.task-card-desc.md-content .md-pre,
.task-card-desc.md-content .md-quote { margin: 4px 0 6px; }
.task-card-desc.md-content .md-hr { margin: 6px 0; }

.task-progress-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

.task-progress-value {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 34px;
  text-align: right;
}

.task-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.task-status-badge,
.task-priority-badge,
.task-tag,
.task-due {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.task-status-badge {
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  background: var(--bg-input);
}

.task-priority-badge {
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-muted);
}
.task-priority-badge.prio-high { color: var(--danger); border-color: rgba(239, 68, 68, 0.4); }
.task-priority-badge.prio-medium { color: var(--warning); border-color: rgba(245, 158, 11, 0.4); }
.task-priority-badge.prio-low { color: var(--success); border-color: rgba(16, 185, 129, 0.4); }

.task-tag {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.25);
  cursor: pointer;
  transition: var(--transition);
}
.task-tag:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.45);
}

.task-due {
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
}
.task-due.overdue {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
}

.task-card-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Task modal form */
.task-form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.task-progress-range {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Give the task modal's dropdowns a consistent custom chevron so they look
   polished and match across browsers (native arrows are hidden). */
#modal-task select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}
#modal-task select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .task-form-row {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   TO-DO: ASSIGNMENT & WORKER PROGRESS DASHBOARD (Option B)
   ========================================================================== */

.task-assign-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}
.task-assign-badge.assigned-to-me {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
  color: var(--info);
}

.task-assignee-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--warning);
}

/* Worker progress dashboard */
.tasks-workers-panel {
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.tasks-workers-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
}

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

.worker-progress-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.worker-progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.worker-progress-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.worker-progress-pct {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}

.worker-progress-meta {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   FLOATING FILE PICKER (matches Gmail-style compose window)
   ========================================================================== */
.file-picker-window {
  position: fixed;
  bottom: 0;
  right: 24px;
  width: 560px;
  max-width: calc(100vw - 32px);
  z-index: 95; /* above compose window (90), no full-screen backdrop */
  display: flex;
  animation: compose-pop-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.file-picker-window.hidden {
  display: none !important;
}

.file-picker-panel {
  width: 100%;
  max-height: calc(100vh - 60px);
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 2px 10px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.theme-light .file-picker-panel {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-bottom: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
}

.file-picker-header {
  background: #1e293b;
  cursor: default;
}

body.theme-light .file-picker-header {
  background: #f1f5f9;
}

@keyframes compose-pop-in {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 768px) {
  .file-picker-window {
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
  }
  .file-picker-panel {
    border-radius: 0 !important;
  }
}

/* ==========================================================================
   MARKDOWN RENDERED CONTENT (Notes & Task descriptions)
   ========================================================================== */
.md-content { line-height: 1.6; word-break: break-word; }
.md-content p { margin: 0 0 8px; }
.md-content p:last-child { margin-bottom: 0; }

.md-content .md-h { margin: 10px 0 6px; font-weight: 700; line-height: 1.3; }
.md-content .md-h1 { font-size: 1.25em; }
.md-content .md-h2 { font-size: 1.15em; }
.md-content .md-h3 { font-size: 1.05em; }
.md-content .md-h4,
.md-content .md-h5,
.md-content .md-h6 { font-size: 1em; color: var(--text-muted); }

.md-content .md-ul,
.md-content .md-ol { margin: 4px 0 8px; padding-left: 20px; }
.md-content .md-ul li,
.md-content .md-ol li { margin: 2px 0; }

.md-content strong { font-weight: 700; }
.md-content em { font-style: italic; }
.md-content del { opacity: 0.7; }

.md-content a {
  color: var(--primary);
  text-decoration: underline;
  word-break: break-all;
}

.md-content .md-code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1px 5px;
}

.md-content .md-pre {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 6px 0 10px;
  overflow-x: auto;
}
.md-content .md-pre code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  white-space: pre;
  background: none;
  border: none;
  padding: 0;
}

.md-content .md-quote {
  border-left: 3px solid var(--primary);
  padding: 4px 12px;
  margin: 6px 0 10px;
  color: var(--text-muted);
  background: rgba(59, 130, 246, 0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.md-content .md-hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 10px 0;
}

/* ==========================================================================
   MARKDOWN EDITOR WRITE / PREVIEW TABS (Note & Task modals)
   ========================================================================== */
.md-editor-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.md-tab {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.md-tab:hover { background: var(--bg-hover); color: var(--text-main); }
.md-tab.active {
  background: var(--bg-active);
  color: var(--primary);
  border-color: var(--border-focus);
}

.md-editor-hint {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.md-preview {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  padding: 12px 14px;
  min-height: 120px;
  max-height: 420px;
  overflow-y: auto;
}

.md-preview-empty {
  color: var(--text-dim);
  font-style: italic;
}

/* ==========================================================================
   MARKDOWN FORMATTING TOOLBAR (Note & Task modals)
   ========================================================================== */
.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  margin-bottom: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.md-tool {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
}
.md-tool:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-color);
}
.md-tool:active {
  background: var(--bg-active);
  color: var(--primary);
}

.md-tool-sep {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 4px;
}

/* ==========================================================================
   MOBILE / PWA — GMAIL-STYLE NATIVE ADAPTATION
   Elements only appear on small screens; desktop layout is untouched.
   ========================================================================== */

/* Hidden by default (desktop). Shown inside the mobile media query. */
.mobile-bottom-nav,
.mobile-fab,
.mobile-scrim,
.mobile-back-btn {
  display: none;
}

@media (max-width: 768px) {
  /* --- App shell fills the viewport, room reserved for bottom nav --- */
  html, body {
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;          /* guard: never allow horizontal overflow (prevents zoom-out) */
  }
  .view-screen, #app, #main-view {
    max-width: 100%;
    overflow-x: hidden;
  }

  .navbar {
    padding: 8px 10px;
    gap: 8px;
  }
  /* Compact brand + hide verbose bits on the top bar */
  .navbar .brand-name { display: none; }
  .navbar .view-switchers { display: none; }        /* replaced by bottom nav */
  .navbar .user-info-text { display: none; }         /* avatar only */
  .navbar .user-profile-menu .btn-icon { display: none; }
  .navbar .nav-center { flex: 1; min-width: 0; }
  /* iOS auto-zooms when focusing inputs with font-size < 16px. Force 16px on
     ALL text inputs/selects/textareas (incl. login) to prevent the zoom-out. */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important;
  }

  .layout-body {
    /* leave space for the 56px bottom nav */
    padding-bottom: 56px;
    min-height: 0;
  }

  /* Fill available space via flex instead of height:100% so the padded
     bottom-nav gap is respected and inner panes can scroll. */
  .app-section.active {
    height: auto;
    flex: 1 1 auto;
  }

  /* --- Notes / Tasks toolbar: stack search on top, actions below --- */
  .notes-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }
  .notes-search-wrapper {
    max-width: 100%;
    width: 100%;
  }
  /* Action cluster wraps into a neat grid so selects/buttons never overflow */
  .notes-toolbar-actions {
    width: 100%;
    gap: 8px;
  }
  /* View + priority selects share the first row, each taking half the width */
  .notes-toolbar-actions .task-filter-select {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    height: 40px;
    line-height: 38px;
  }
  /* Report / refresh buttons: compact, equal-width, on their own row(s) */
  .notes-toolbar-actions .btn-sm {
    flex: 1 1 auto;
    justify-content: center;
    height: 40px;
  }

  /* --- Sidebar becomes a slide-in drawer --- */
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px !important;
    min-width: 280px !important;
    max-width: 85vw;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    border-radius: 0;
  }
  /* On mobile the collapsed (icon-rail) desktop mode should not apply */
  .sidebar.collapsed {
    width: 280px !important;
    min-width: 280px !important;
  }
  .sidebar.collapsed .nav-text-group,
  .sidebar.collapsed .menu-label,
  .sidebar.collapsed .sidebar-bottom,
  .sidebar.collapsed .btn-compose span,
  .sidebar.collapsed .task-progress-summary,
  .sidebar.collapsed .notes-tags-list {
    display: revert !important;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .mobile-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
  }
  .mobile-scrim.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* --- List / detail stack: list full width, detail slides over --- */
  .app-section {
    flex-direction: column;
    min-height: 0;            /* allow children to shrink so scroll works */
  }

  .mail-list-pane,
  .notes-main-pane,
  .files-main-pane,
  .calendar-main-pane {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 auto;
    min-height: 0;            /* critical: enables inner overflow scrolling */
    border-right: none;
  }

  /* The scrollable message list needs a constrained, scrollable box */
  .mail-list-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mail-detail-pane {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    max-width: 100% !important;
    z-index: 120;               /* above list, below drawer */
    background: var(--bg-main);
    transform: translateX(100%);
    transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
  }
  /* Slide the detail in when a message is open (JS toggles this class) */
  .mail-detail-pane.mobile-detail-open {
    transform: translateX(0);
  }

  /* Show the back arrow in the detail toolbar */
  .mobile-back-btn {
    display: inline-flex !important;
    margin-right: 4px;
  }

  /* --- Detail toolbar: single clean row, Gmail-style icon actions --- */
  .detail-toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: 52px;
    padding: 0 6px;
    gap: 2px;
    flex-wrap: nowrap;
    overflow: hidden;
  }

  /* The action group scrolls horizontally instead of wrapping into rows */
  .detail-toolbar .toolbar-left {
    flex: 1;
    min-width: 0;
    gap: 2px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .detail-toolbar .toolbar-left::-webkit-scrollbar { display: none; }

  /* Compact icon-only action buttons (hide the text labels) */
  .detail-toolbar .toolbar-left .btn {
    flex: 0 0 auto;
    padding: 0;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    justify-content: center;
  }
  .detail-toolbar .toolbar-left .btn span { display: none; }
  .detail-toolbar .toolbar-left .btn svg {
    width: 18px;
    height: 18px;
    margin: 0;
  }

  .detail-toolbar .toolbar-right {
    flex: 0 0 auto;
    gap: 0;
    padding-left: 4px;
    margin-left: 2px;
    border-left: 1px solid var(--border-color);
  }
  .detail-toolbar .toolbar-right .btn-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }

  /* Hide desktop-only power-user buttons on mobile to keep the bar clean */
  .detail-toolbar #btn-toggle-canvas,
  .detail-toolbar .mobile-hide {
    display: none !important;
  }

  .detail-toolbar .mobile-back-btn {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    min-width: 40px;
  }

  /* --- Attachments: single-column cards, compact icon-only actions --- */
  .attach-pills {
    grid-template-columns: 1fr;   /* one card per row so nothing overflows */
    gap: 8px;
  }

  .attachment-item-card {
    padding: 8px 10px;
    gap: 8px;
  }

  /* Icon-only action buttons keep the card from overflowing the screen */
  .attachment-item-card .att-card-actions {
    gap: 2px;
  }
  .attachment-item-card .btn-att-action {
    padding: 0;
    width: 36px;
    height: 36px;
    justify-content: center;
    flex: 0 0 auto;
  }
  .attachment-item-card .btn-att-action span {
    display: none;              /* hide "Preview" / "Save to Files" / "Download" text */
  }
  .attachment-item-card .btn-att-action svg {
    margin: 0;
  }

  /* Give the reading canvas room; it should not be squeezed by attachments */
  .mail-body-container {
    padding: 12px 14px;
  }
  .mail-paper-canvas {
    padding: 16px 16px;
  }

  /* --- Bottom navigation bar --- */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 56px;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    z-index: 130;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s ease;
  }
  .mobile-nav-item svg { opacity: 0.8; }
  .mobile-nav-item.active {
    color: var(--primary);
  }
  .mobile-nav-item.active svg { opacity: 1; }

  /* --- Floating Action Button (compose) --- */
  .mobile-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 18px;
    bottom: 72px;               /* above the bottom nav */
    width: 56px;
    height: 56px;
    border-radius: 18px;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.45);
    cursor: pointer;
    z-index: 135;
  }
  .mobile-fab:active { transform: scale(0.95); }

  /* Compose full-screen behavior on phones is already handled by the earlier
     .compose-window mobile rule; nothing extra needed here. */

  /* Floating file picker goes full-screen too (consistency with compose) */
  .file-picker-window { bottom: 0; top: 0; }
  .file-picker-panel { max-height: 100vh; border-radius: 0; }

  /* Modals must sit above the bottom nav (130) and FAB (135) so their
     footers (e.g. Sign Out) aren't covered on mobile. */
  .modal-overlay {
    z-index: 300 !important;
  }

  /* Modals use more of the screen */
  .modal-card {
    max-width: 96vw !important;
    max-height: 92vh !important;
  }
  .modal-card.modal-lg { max-width: 96vw !important; }
  .modal-body { max-height: 70vh; overflow-y: auto; }

  /* --- Profile modal: stack avatar over details, scrollable tabs --- */
  .profile-tabs-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
  }
  .profile-tabs-nav::-webkit-scrollbar { display: none; }
  .profile-tabs-nav .tab-btn {
    flex: 0 0 auto;
    font-size: 12px !important;
    padding: 10px 10px !important;
  }
  /* The avatar+details row and any form-row stack vertically */
  #ptab-info > div:first-child {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 14px !important;
  }
  #ptab-info > div:first-child > div:first-child {
    width: 100% !important;       /* avatar box full width, centered */
  }
  .form-row {
    flex-direction: column !important;
    gap: 0 !important;
  }
  .form-row .form-group { width: 100% !important; }

  /* Profile modal footer: keep buttons compact and on one row */
  #modal-profile .modal-footer {
    flex-wrap: nowrap;
    gap: 8px;
  }
  #modal-profile .modal-footer .btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  #modal-profile .modal-footer > div {
    flex: 0 0 auto;
  }

  /* Larger tap targets */
  .mail-list-item { padding: 12px 14px; }
  .btn-icon { min-width: 40px; min-height: 40px; }
}

/* Small phones */
@media (max-width: 380px) {
  .mobile-nav-item span { font-size: 9px; }
}

/* ==========================================================================
   SECURITY & AUDIT (login trail, active sessions, revoke)
   ========================================================================== */
.sec-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--border-color);
}
.sec-ev-ok   { background: rgba(16, 185, 129, 0.12); color: var(--success); border-color: rgba(16, 185, 129, 0.35); }
.sec-ev-fail { background: rgba(239, 68, 68, 0.12);  color: var(--danger);  border-color: rgba(239, 68, 68, 0.35); }
.sec-ev-warn { background: rgba(245, 158, 11, 0.12); color: var(--warning); border-color: rgba(245, 158, 11, 0.35); }
.sec-ev-mute { background: var(--bg-input); color: var(--text-muted); }

.sec-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; }
.sec-detail { color: var(--text-muted); font-size: 12px; }
.sec-empty { text-align: center; color: var(--text-muted); padding: 24px; }

.sec-tag-you {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  vertical-align: middle;
}

/* User self-service active-session rows (profile Security tab) */
.sessions-list { display: flex; flex-direction: column; gap: 8px; }
.sessions-empty { font-size: 13px; color: var(--text-muted); padding: 10px 0; }
.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}
.session-device { font-size: 13px; font-weight: 600; color: var(--text-main); }
.session-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; word-break: break-word; }
.session-action { flex-shrink: 0; }
