/* ============================================
   Discord Bot Web Panel — Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ── */
:root {
  /* Discord-inspired colors */
  --blurple: #5865F2;
  --blurple-dark: #4752C4;
  --green: #57F287;
  --yellow: #FEE75C;
  --red: #ED4245;
  --fuchsia: #EB459E;
  --white: #FFFFFF;

  /* Background layers */
  --bg-primary: #0b0d14;
  --bg-secondary: #111420;
  --bg-tertiary: #161a28;
  --bg-card: rgba(22, 26, 40, 0.7);
  --bg-card-hover: rgba(30, 35, 55, 0.85);
  --bg-glass: rgba(88, 101, 242, 0.06);
  --bg-input: rgba(0, 0, 0, 0.25);

  /* Text */
  --text-primary: #E0E0EA;
  --text-secondary: #8B8FA3;
  --text-muted: #5C5F72;
  --text-accent: #A8B1FF;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(88, 101, 242, 0.3);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #5865F2 0%, #EB459E 100%);
  --gradient-bg: radial-gradient(ellipse at 20% 50%, rgba(88, 101, 242, 0.08) 0%, transparent 50%),
                 radial-gradient(ellipse at 80% 20%, rgba(235, 69, 158, 0.06) 0%, transparent 50%),
                 radial-gradient(ellipse at 50% 80%, rgba(87, 242, 135, 0.04) 0%, transparent 50%);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(88, 101, 242, 0.15);

  /* Spacing */
  --sidebar-width: 260px;
  --header-height: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--gradient-bg);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--text-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--blurple); }

/* ── Login Page ── */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  text-align: center;
  animation: fadeInUp 0.6s ease;
}

.login-card .logo {
  font-size: 2.4rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.login-card .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  margin-bottom: 16px;
}

.login-card input[type="password"]:focus {
  border-color: var(--blurple);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.2);
}

.login-card .error-msg {
  color: var(--red);
  font-size: 0.85rem;
  margin-bottom: 12px;
  min-height: 20px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 20px rgba(88, 101, 242, 0.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(88, 101, 242, 0.45);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}

.btn-danger {
  background: var(--red);
  color: white;
}
.btn-danger:hover {
  background: #d63a3d;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
}

.btn-full { width: 100%; }

/* ── Layout ── */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-slow);
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header .brand {
  font-size: 1.3rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header .brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  -webkit-text-fill-color: white;
}

.sidebar-header .bot-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 8px;
}

.sidebar-header .bot-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}

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

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 16px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-link.active {
  background: rgba(88, 101, 242, 0.12);
  color: var(--blurple);
}

.nav-link .icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
}

.nav-link .badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-footer .logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: none;
  border: none;
  width: 100%;
  font-family: inherit;
}

.sidebar-footer .logout-btn:hover {
  background: rgba(237, 66, 69, 0.1);
  color: var(--red);
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.page-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(11, 13, 20, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header .description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.page-body {
  padding: 28px 32px;
}

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card:nth-child(1)::before { background: var(--blurple); }
.stat-card:nth-child(2)::before { background: var(--green); }
.stat-card:nth-child(3)::before { background: var(--fuchsia); }
.stat-card:nth-child(4)::before { background: var(--yellow); }
.stat-card:nth-child(5)::before { background: var(--red); }

.stat-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
  font-size: 1.6rem;
  margin-bottom: 12px;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Data Cards / Panels ── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-normal);
}

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

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

.card-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px 22px;
}

.card-body.no-padding {
  padding: 0;
}

/* ── Grid Layouts ── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

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

/* ── Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.data-table tbody td {
  padding: 12px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

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

/* ── Member Row ── */
.member-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.member-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-tertiary);
}

.member-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.member-tag {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Status Dots ── */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot.online { background: var(--green); }
.status-dot.idle { background: var(--yellow); }
.status-dot.dnd { background: var(--red); }
.status-dot.invisible { background: var(--text-muted); }
.status-dot.offline { background: var(--text-muted); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
}

/* ── Activity Tags ── */
.activity-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  background: rgba(88, 101, 242, 0.1);
  color: var(--text-accent);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-tag.gaming {
  background: rgba(87, 242, 135, 0.1);
  color: var(--green);
}

.activity-tag.spotify {
  background: rgba(29, 185, 84, 0.1);
  color: #1DB954;
}

.activity-tag.streaming {
  background: rgba(145, 70, 255, 0.1);
  color: #9146FF;
}

/* ── Input / Form ── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--blurple);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.15);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238B8FA3' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(20px);
  transition: transform var(--transition-slow);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

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

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

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: rgba(237, 66, 69, 0.15);
  color: var(--red);
}

.modal-body {
  padding: 24px;
}

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

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  min-width: 280px;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.4s ease;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--blurple); }
.toast.warning { border-left: 3px solid var(--yellow); }

.toast .toast-icon { font-size: 1.3rem; }
.toast .toast-message { font-size: 0.9rem; flex: 1; }

/* ── Search ── */
.search-input {
  position: relative;
}

.search-input input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-input input:focus {
  border-color: var(--blurple);
}

.search-input .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Loading ── */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-light);
  border-top-color: var(--blurple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  padding: 60px;
  color: var(--text-secondary);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ── Log Viewer ── */
.log-viewer {
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  line-height: 1.8;
  max-height: 500px;
  overflow-y: auto;
  color: var(--text-secondary);
}

.log-viewer .log-line {
  padding: 2px 0;
  display: flex;
  gap: 12px;
}

.log-viewer .log-time {
  color: var(--text-muted);
  white-space: nowrap;
}

.log-viewer .log-level {
  font-weight: 700;
  min-width: 50px;
}

.log-viewer .log-level.info { color: var(--blurple); }
.log-viewer .log-level.warn { color: var(--yellow); }
.log-viewer .log-level.error { color: var(--red); }

/* ── Channel List ── */
.channel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.channel-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.channel-item .channel-icon {
  font-size: 1.1rem;
  color: var(--text-muted);
  width: 22px;
  text-align: center;
}

.channel-item .channel-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ── Bot Control ── */
.control-grid {
  align-items: stretch;
}

.compact-grid {
  gap: 14px;
  margin-bottom: 0;
}

.bot-profile-panel {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 96px;
}

.bot-profile-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-accent);
  flex: 0 0 auto;
}

.bot-profile-name {
  font-size: 1.25rem;
  line-height: 1.2;
  font-weight: 800;
  margin-bottom: 4px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.control-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 14px;
  color: var(--text-secondary);
  font-size: 0.86rem;
  line-height: 1.4;
}

.control-checkbox input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--blurple);
  flex: 0 0 auto;
}

.presence-preview {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.control-embed-layout {
  align-items: start;
}

.control-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.control-actions .btn {
  flex: 1 1 180px;
}

.embed-preview-shell {
  min-height: 420px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.2);
  padding: 16px;
  overflow: hidden;
}

.embed-preview-content {
  white-space: pre-wrap;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.embed-preview-card {
  position: relative;
  border-left: 4px solid var(--blurple);
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  padding: 14px;
  min-height: 72px;
  overflow: hidden;
}

.embed-preview-author {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 700;
  margin-bottom: 8px;
}

.embed-preview-title {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-primary);
  padding-right: 88px;
}

.embed-preview-desc {
  white-space: pre-wrap;
  color: var(--text-secondary);
  padding-right: 88px;
}

.embed-preview-thumb {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.embed-preview-image {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  margin-top: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.embed-preview-footer {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Task / Settings Panels ── */
.task-list {
  display: flex;
  flex-direction: column;
}

.task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.task-title {
  font-weight: 700;
  color: var(--text-primary);
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.task-actions,
.settings-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

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

.presence-rotation-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.settings-table {
  display: flex;
  flex-direction: column;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

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

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

.settings-kv div {
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  min-width: 0;
}

.settings-kv span {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.settings-kv strong {
  display: block;
  color: var(--text-primary);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

/* ── User Management / Chat Logs ── */
.compact-stats .stat-card {
  padding: 18px;
}

.user-management-layout {
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr);
  align-items: start;
}

.user-list {
  max-height: 680px;
  overflow-y: auto;
}

.user-list-row {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  text-align: left;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-list-row:hover,
.user-list-row.active {
  background: rgba(88, 101, 242, 0.1);
}

.user-list-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.user-list-main strong,
.user-list-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-list-main span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.managed-profile {
  display: flex;
  align-items: center;
  gap: 16px;
}

.managed-profile img {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-accent);
}

.managed-profile h3 {
  font-size: 1.25rem;
  line-height: 1.2;
  margin-bottom: 4px;
}

.detail-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}

.detail-section-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.role-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
}

.role-chip-row,
.permission-grid,
.chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 4px 8px 4px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 0.82rem;
}

.role-chip button {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(237, 66, 69, 0.14);
  color: var(--red);
  cursor: pointer;
  line-height: 1;
}

.role-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.permission-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  background: rgba(87, 242, 135, 0.08);
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 600;
}

.permission-tag.muted {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.mini-log-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.82rem;
}

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

.mini-log-row span {
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.mini-log-row small {
  color: var(--text-muted);
}

.chat-controls {
  display: grid;
  grid-template-columns: minmax(140px, 0.6fr) minmax(360px, 2fr) 100px minmax(170px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.chat-scope-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.chat-realtime-toggle {
  align-items: center;
  margin: 0 0 6px;
  white-space: nowrap;
}

.chat-log-viewer {
  max-height: 650px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.22);
}

.chat-message-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.chat-message-main {
  min-width: 0;
}

.chat-message-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  font-size: 0.8rem;
}

.chat-message-head strong {
  color: var(--text-primary);
  font-size: 0.9rem;
}

.chat-message-head span,
.chat-message-head a {
  color: var(--text-muted);
}

.chat-message-content {
  margin-top: 3px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-attachments {
  margin-top: 8px;
}

.chat-attachments a {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: rgba(88, 101, 242, 0.1);
  font-size: 0.78rem;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ── Animations ── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(60px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.fade-in {
  animation: fadeInUp 0.5s ease forwards;
}

/* Staggered card animations */
.stats-grid .stat-card:nth-child(1) { animation: fadeInUp 0.4s ease 0.05s both; }
.stats-grid .stat-card:nth-child(2) { animation: fadeInUp 0.4s ease 0.1s both; }
.stats-grid .stat-card:nth-child(3) { animation: fadeInUp 0.4s ease 0.15s both; }
.stats-grid .stat-card:nth-child(4) { animation: fadeInUp 0.4s ease 0.2s both; }
.stats-grid .stat-card:nth-child(5) { animation: fadeInUp 0.4s ease 0.25s both; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .presence-rotation-row,
  .settings-row,
  .task-row,
  .chat-controls,
  .chat-scope-panel {
    grid-template-columns: 1fr;
  }
  .task-actions,
  .settings-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .page-header {
    padding: 16px 20px;
  }
  .page-body {
    padding: 20px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .user-list-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }
  .user-list-row .status-badge {
    grid-column: 2;
    width: max-content;
  }
  .role-editor,
  .mini-log-row {
    grid-template-columns: 1fr;
  }
  .mobile-menu-btn {
    display: flex !important;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.3rem;
}

/* ── Misc ── */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blurple { color: var(--blurple); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.hidden { display: none !important; }

/* Application mail uses a paper reading surface without changing other pages. */
.main-content:has(.app-mails-page) { min-width: 0; }
.nav-link.app-mails-nav.active,
.nav-link.app-mails-nav:hover {
  background: #e4d6bd;
  color: #493f31;
  box-shadow: none;
}

.app-mails-page {
  --mail-ink: #332f28;
  --mail-muted: #746b5d;
  --mail-rule: #ddd4c5;
  --mail-accent: #806246;
  min-height: 100vh;
  min-width: 0;
  padding: 34px;
  color: var(--mail-ink);
  background: #f5f1e8;
}

.app-mails-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 26px;
}

.app-mails-header h1 { color: var(--mail-ink); font-size: 1.7rem; font-weight: 650; }
.app-mails-header p { margin-top: 3px; color: var(--mail-muted); font-size: .88rem; }

.app-mails-filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--mail-rule);
}

.app-mails-filters label { display: flex; min-width: 0; flex-direction: column; gap: 5px; font-size: .82rem; color: var(--mail-muted); }
.app-mails-search { flex: 1; min-width: 180px; }
.app-mails-filters input,
.app-mails-filters select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #c8bdaa;
  border-radius: 5px;
  background: #fffdf8;
  color: var(--mail-ink);
  font: inherit;
}
.app-mails-filters select { min-width: 180px; max-width: 290px; }
.app-mails-filters input::placeholder { color: #8b8172; }

.app-mails-page .app-mail-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid #c8bdaa;
  border-radius: 5px;
  background: #fffdf8;
  color: #574634;
  font: inherit;
  font-size: .84rem;
  text-decoration: none;
  cursor: pointer;
}
.app-mails-page .app-mail-button:hover { border-color: var(--mail-accent); background: #ece3d2; color: #493823; }
.app-mails-page .app-mail-button-solid { background: #755b40; border-color: #755b40; color: #fffdf8; }
.app-mails-page .app-mail-button-solid:hover { background: #624b35; color: white; }
.app-mails-page .app-mail-button:disabled { opacity: .48; cursor: default; }
.app-mails-page :is(button, input, select, a):focus-visible { outline: 2px solid #866b49; outline-offset: 3px; box-shadow: none; }

.app-mails-status { min-height: 30px; padding: 7px 0; color: #795137; font-size: .85rem; }
.app-mails-workspace { display: grid; grid-template-columns: minmax(260px, .9fr) minmax(0, 1.7fr); gap: 24px; align-items: start; }
.app-mails-inbox { min-width: 0; }
.app-mails-list { border-top: 1px solid var(--mail-rule); }
.app-mail-row {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 6px;
  padding: 18px 14px;
  border: 0;
  border-bottom: 1px solid var(--mail-rule);
  border-radius: 0;
  background: transparent;
  color: var(--mail-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.app-mail-row:hover { background: #ece5d8; }
.app-mail-row[aria-pressed="true"] { background: #e8dec9; }
.app-mail-row strong { font-size: .94rem; line-height: 1.45; overflow-wrap: anywhere; }
.app-mail-row-top { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.app-mail-row time { color: var(--mail-muted); font-size: .72rem; }
.app-mail-app { color: #775734; font-size: .76rem; font-weight: 650; overflow-wrap: anywhere; }
.app-mail-sender { color: var(--mail-muted); font-size: .79rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-mail-preview { color: var(--mail-muted); font-size: .83rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.app-mails-pagination { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 16px; color: var(--mail-muted); font-size: .8rem; }
.app-mail-placeholder { padding: 28px 18px; color: var(--mail-muted); font-size: .9rem; }

.app-mail-detail { min-width: 0; min-height: 340px; border: 1px solid var(--mail-rule); background: #fffdf8; border-radius: 6px; }
.app-mail-detail-header { padding: 26px 28px 22px; border-bottom: 1px solid var(--mail-rule); }
.app-mail-detail h2 { margin: 7px 0 20px; color: var(--mail-ink); font-size: 1.3rem; line-height: 1.5; font-weight: 650; overflow-wrap: anywhere; }
.app-mail-metadata { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 16px; font-size: .83rem; }
.app-mail-metadata dt { color: var(--mail-muted); }
.app-mail-metadata dd { margin: 0; overflow-wrap: anywhere; }
.app-mail-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.app-mail-actions:empty { display: none; }
.app-mail-body { padding: 28px; color: var(--mail-ink); font-size: .94rem; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; }
.app-mail-attachments { padding: 18px 28px; border-top: 1px solid var(--mail-rule); font-size: .84rem; }
.app-mail-attachments h3 { margin-bottom: 8px; font-size: .85rem; color: var(--mail-muted); }
.app-mail-attachments ul { padding-left: 18px; overflow-wrap: anywhere; }

@media (max-width: 1150px) {
  .app-mails-page { padding: 28px 22px; }
  .app-mails-workspace { grid-template-columns: minmax(230px, .9fr) minmax(0, 1.3fr); gap: 16px; }
  .app-mail-detail-header, .app-mail-body { padding: 22px; }
}

@media (max-width: 900px) {
  .app-mails-workspace { grid-template-columns: minmax(0, 1fr); }
  .app-mails-list { max-height: 420px; overflow-y: auto; }
  .app-mail-detail { min-height: 220px; }
}

@media (max-width: 768px) {
  .app-mails-page { padding: 76px 16px 24px; }
  .app-mails-header { align-items: flex-start; margin-bottom: 20px; }
  .app-mails-header h1 { font-size: 1.45rem; }
  .app-mails-search { flex-basis: 100%; }
  .app-mails-filters label:not(.app-mails-search) { flex: 1; }
  .app-mails-filters select { min-width: 0; max-width: none; }
  .app-mail-detail-header, .app-mail-body { padding: 20px; }
  .app-mail-metadata { grid-template-columns: 1fr; gap: 1px; }
  .app-mail-metadata dd { margin-bottom: 9px; }
}
