/* AI BOSS Web — Premium Dark Interface */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ═══════════════════════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════════════════════ */
:root {
  --font-display: 'Outfit', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;

  --bg-root: #050506;
  --bg-primary: #09090b;
  --bg-secondary: #111113;
  --bg-card: #16161a;
  --bg-card-hover: #1c1c21;
  --bg-glass: rgba(255, 255, 255, 0.025);
  --bg-glass-hover: rgba(255, 255, 255, 0.05);
  --bg-input: rgba(255, 255, 255, 0.04);
  --bg-input-focus: rgba(255, 255, 255, 0.07);

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-active: rgba(245, 158, 11, 0.3);

  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #52525b;
  --text-disabled: #3f3f46;

  --accent: #f59e0b;
  --accent-hover: #d97706;
  --accent-soft: rgba(245, 158, 11, 0.12);
  --accent-glow: rgba(245, 158, 11, 0.08);

  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 40px rgba(245, 158, 11, 0.06);

  --sidebar-width: 240px;
  --sidebar-collapsed: 68px;
  --topbar-height: 60px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light mode override */
[data-theme="light"] {
  --bg-root: #f8f8fa;
  --bg-primary: #ffffff;
  --bg-secondary: #f4f4f5;
  --bg-card: #ffffff;
  --bg-card-hover: #fafafa;
  --bg-glass: rgba(0, 0, 0, 0.02);
  --bg-glass-hover: rgba(0, 0, 0, 0.04);
  --bg-input: rgba(0, 0, 0, 0.04);
  --bg-input-focus: rgba(0, 0, 0, 0.06);
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --text-primary: #09090b;
  --text-secondary: #52525b;
  --text-muted: #a1a1aa;
  --text-disabled: #d4d4d8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

/* ═══════════════════════════════════════════════════════
   TELEGRAM VARIABLE OVERRIDES (for reused Mini App modules)
   ═══════════════════════════════════════════════════════ */
:root, [data-theme="dark"] {
  --tg-bg: var(--bg-primary);
  --tg-text: var(--text-primary);
  --tg-hint: var(--text-muted);
  --tg-link: var(--accent);
  --tg-btn: var(--accent);
  --tg-btn-text: #000;
  --tg-secondary-bg: var(--bg-secondary);
  --tg-section-bg: var(--bg-card);
  --tg-section-header: var(--text-muted);
  --tg-subtitle: var(--text-secondary);
  --tg-accent: var(--accent);
  --tg-destructive: var(--danger);
  --tg-theme-bg-color: var(--bg-primary);
  --tg-theme-text-color: var(--text-primary);
  --tg-theme-hint-color: var(--text-muted);
  --tg-theme-link-color: var(--accent);
  --tg-theme-button-color: var(--accent);
  --tg-theme-button-text-color: #000;
  --tg-theme-secondary-bg-color: var(--bg-secondary);
  --tg-theme-section-bg-color: var(--bg-card);
  --tg-theme-section-header-text-color: var(--text-muted);
  --tg-theme-subtitle-text-color: var(--text-secondary);
  --tg-theme-accent-text-color: var(--accent);
  --tg-theme-destructive-text-color: var(--danger);
}

[data-theme="light"] {
  --tg-bg: var(--bg-primary);
  --tg-text: var(--text-primary);
  --tg-hint: var(--text-muted);
  --tg-link: var(--accent);
  --tg-btn: var(--accent);
  --tg-btn-text: #000;
  --tg-secondary-bg: var(--bg-secondary);
  --tg-section-bg: var(--bg-card);
  --tg-section-header: var(--text-muted);
  --tg-subtitle: var(--text-secondary);
  --tg-accent: var(--accent);
  --tg-destructive: var(--danger);
  --tg-theme-bg-color: var(--bg-primary);
  --tg-theme-text-color: var(--text-primary);
  --tg-theme-hint-color: var(--text-muted);
  --tg-theme-link-color: var(--accent);
  --tg-theme-button-color: var(--accent);
  --tg-theme-button-text-color: #000;
  --tg-theme-secondary-bg-color: var(--bg-secondary);
  --tg-theme-section-bg-color: var(--bg-card);
}

/* ═══════════════════════════════════════════════════════
   APP.CSS OVERRIDES — Dark theme adaptation for reused modules
   ═══════════════════════════════════════════════════════ */

/* ─── Integration cards: grid layout ─── */
.main-content .section-header {
  color: var(--text-muted) !important;
  font-family: var(--font-display) !important;
  font-weight: 600 !important;
  font-size: 11px !important;
  letter-spacing: 1px !important;
  text-transform: uppercase !important;
  margin-bottom: 12px !important;
  padding: 0 !important;
}

.main-content .section-header ~ .mp-connector {
  break-inside: avoid;
  margin-bottom: 0;
}

/* Wrap connectors in a CSS grid via section grouping */
.main-content {
  --connector-grid: repeat(auto-fill, minmax(320px, 1fr));
}

/* Make integrations page use grid */
.main-content .section-header ~ .mp-connector,
.main-content .mp-connector {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  color: var(--text-primary) !important;
  padding: 20px !important;
  display: flex;
  flex-direction: column;
}

.mp-connector-head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  margin-bottom: 6px !important;
}

.mp-connector-title {
  color: var(--text-primary) !important;
  font-family: var(--font-display) !important;
  font-weight: 600 !important;
  font-size: 15px !important;
}

.mp-connector-title svg { width: 20px; height: 20px; vertical-align: middle; margin-right: 6px; }

.mp-connector-desc {
  color: var(--text-secondary) !important;
  font-size: 12px !important;
  line-height: 1.4 !important;
  margin-bottom: 16px !important;
  flex: 1;
}

.mp-status {
  font-size: 11px !important;
  font-weight: 600 !important;
  white-space: nowrap !important;
}

.mp-status.not-connected { color: var(--text-muted) !important; }
.mp-status.connected { color: var(--success) !important; }
.mp-status.error { color: var(--danger) !important; }
.mp-status.checking { color: var(--text-muted) !important; }

.mp-form-actions {
  display: flex !important;
  gap: 8px !important;
  margin-top: auto !important;
}

/* ─── Buttons ─── */
.action-btn {
  background: var(--bg-glass) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  font-family: var(--font-body) !important;
  font-size: 13px !important;
  padding: 9px 16px !important;
  transition: all 0.15s !important;
  flex: 1;
  text-align: center;
}

.action-btn:hover {
  background: var(--bg-glass-hover) !important;
  border-color: var(--border-hover) !important;
  color: var(--text-primary) !important;
}

.action-btn:not(.secondary):not(.destructive) {
  background: var(--accent) !important;
  color: #000 !important;
  border-color: var(--accent) !important;
  font-weight: 600 !important;
}

.action-btn:not(.secondary):not(.destructive):hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
}

.action-btn.destructive {
  background: var(--danger-soft) !important;
  color: var(--danger) !important;
  border-color: rgba(239,68,68,0.15) !important;
}

.action-btn.destructive:hover {
  background: rgba(239,68,68,0.2) !important;
}

.action-btn.secondary {
  background: var(--bg-glass) !important;
  color: var(--text-secondary) !important;
}

/* ─── Forms ─── */
.mp-form-input {
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-md) !important;
}

.mp-form-input:focus {
  border-color: var(--accent) !important;
  background: var(--bg-input-focus) !important;
}

.mp-form-label { color: var(--text-secondary) !important; font-size: 13px !important; }
.mp-error { color: var(--danger) !important; background: var(--danger-soft) !important; border-radius: var(--radius-md) !important; }
.mp-success { color: var(--success) !important; background: var(--success-soft) !important; border-radius: var(--radius-md) !important; }

/* ─── Mail ─── */
.mail-item {
  border-bottom: 1px solid var(--border) !important;
  padding: 12px 0 !important;
}

.mail-item.unread { border-left: 3px solid var(--accent) !important; padding-left: 12px !important; }
.mail-from, .mail-subject { color: var(--text-primary) !important; }
.mail-snippet, .mail-date { color: var(--text-muted) !important; }

/* ─── Card ─── */
.card {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-lg) !important;
}

.card-subtitle { color: var(--text-secondary) !important; }

/* ─── Hide mobile tab bar ─── */
.main-content #tabs { display: none !important; }

/* ─── Connector grid injection via JS wrapper ─── */
.w-connector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.w-connector-grid .mp-connector {
  margin-bottom: 0 !important;
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-root);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

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

::selection {
  background: var(--accent-soft);
  color: var(--accent);
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ═══════════════════════════════════════════════════════
   AUTH / LANDING PAGE
   ═══════════════════════════════════════════════════════ */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* On very wide screens, add background behind the centered container */
@media (min-width: 1401px) {
  body:has(.auth-page) {
    background: var(--bg-root);
  }
}

/* Left panel — branding */
.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 60px;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 40%, rgba(245, 158, 11, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 60% 60% at 80% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 70%),
    radial-gradient(ellipse 50% 80% at 50% 90%, rgba(139, 92, 246, 0.04) 0%, transparent 60%);
  animation: meshPulse 12s ease-in-out infinite alternate;
}

@keyframes meshPulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

.auth-brand-content {
  position: relative;
  z-index: 1;
  max-width: 480px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 48px;
}

.auth-logo-mark {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  color: #000;
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.2);
}

.auth-logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.auth-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(36px, 4vw, 52px);
  line-height: 1.1;
  letter-spacing: -1.5px;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.auth-title .accent { color: var(--accent); }

.auth-subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 400px;
  margin-bottom: 48px;
}

.auth-features {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-feature {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-secondary);
  font-size: 14px;
  animation: fadeInUp 0.6s var(--ease-out) backwards;
}

.auth-feature:nth-child(1) { animation-delay: 0.3s; }
.auth-feature:nth-child(2) { animation-delay: 0.4s; }
.auth-feature:nth-child(3) { animation-delay: 0.5s; }
.auth-feature:nth-child(4) { animation-delay: 0.6s; }

.auth-feature-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

/* Right panel — login */
.auth-login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
}

.auth-card {
  width: 100%;
  max-width: 360px;
  animation: fadeInUp 0.5s var(--ease-out) 0.2s backwards;
}

.auth-card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.auth-card-sub {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 36px;
}

.auth-tg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 24px;
  background: #2AABEE;
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.auth-tg-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.3s;
}

.auth-tg-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(42, 171, 238, 0.3); }
.auth-tg-btn:hover::before { opacity: 1; }
.auth-tg-btn:active { transform: translateY(0); }

.auth-tg-btn svg { width: 22px; height: 22px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 28px 0;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-demo-btn {
  display: block;
  width: 100%;
  padding: 12px 24px;
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.auth-demo-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.auth-footer {
  margin-top: 48px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Floating grid dots (decorative) */
.auth-brand::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 30px 30px;
  opacity: 0.3;
  mask-image: radial-gradient(ellipse 70% 70% at 30% 50%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 30% 50%, black 20%, transparent 70%);
}

/* ═══════════════════════════════════════════════════════
   MAIN APP LAYOUT
   ═══════════════════════════════════════════════════════ */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
  transition: grid-template-columns 0.3s var(--ease-out);
}

.app-layout.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed) 1fr;
}

/* ─── Sidebar ─── */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 100;
  transition: width 0.3s var(--ease-out);
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  color: #000;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}

.sidebar-collapsed .sidebar-logo-text { opacity: 0; width: 0; }

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

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  position: relative;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.sidebar-item:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-icon svg { width: 20px; height: 20px; fill: currentColor; }

.sidebar-label {
  overflow: hidden;
  transition: opacity 0.2s, width 0.3s;
}

.sidebar-collapsed .sidebar-label { opacity: 0; width: 0; }

.sidebar-badge {
  margin-left: auto;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  transition: opacity 0.2s;
}

.sidebar-collapsed .sidebar-badge { opacity: 0; }

.sidebar-section {
  padding: 16px 12px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-collapsed .sidebar-section { opacity: 0; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.sidebar-toggle:hover { color: var(--text-secondary); background: var(--bg-glass); }
.sidebar-toggle svg { width: 18px; height: 18px; transition: transform 0.3s var(--ease-out); }
.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }

/* ─── Topbar ─── */
.topbar {
  grid-area: topbar;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 16px;
}

.topbar-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.3px;
  flex: 1;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 200px;
}

.topbar-search:hover { border-color: var(--border-hover); color: var(--text-secondary); }
.topbar-search svg { width: 15px; height: 15px; }
.topbar-search kbd {
  margin-left: auto;
  font-family: var(--font-body);
  font-size: 11px;
  padding: 1px 6px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

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

.topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.topbar-btn:hover { background: var(--bg-glass); border-color: var(--border-hover); color: var(--text-primary); }
.topbar-btn svg { width: 18px; height: 18px; }

.topbar-avatar-wrap {
  position: relative;
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.topbar-avatar:hover { box-shadow: 0 0 0 3px var(--accent-soft); }
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Profile dropdown */
.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  display: none;
  animation: fadeInUp 0.2s var(--ease-out);
  overflow: hidden;
}

.profile-dropdown.open { display: block; }

.profile-dropdown-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
}

.profile-dd-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
  overflow: hidden;
  flex-shrink: 0;
}

.profile-dd-avatar img { width: 100%; height: 100%; object-fit: cover; }

.profile-dd-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}

.profile-dd-username {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.profile-dropdown-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.profile-dd-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.profile-dd-row-label { color: var(--text-muted); }
.profile-dd-row-value { color: var(--text-primary); font-weight: 500; }

.profile-dropdown-footer {
  padding: 10px 16px;
}

.profile-dd-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.profile-dd-btn:hover { background: var(--danger-soft); }

/* ─── Main content ─── */
.main-content {
  grid-area: main;
  padding: 28px;
  overflow-y: auto;
  max-height: calc(100vh - var(--topbar-height));
}

/* ═══════════════════════════════════════════════════════
   SHARED COMPONENTS
   ═══════════════════════════════════════════════════════ */

/* Cards */
.w-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all 0.2s var(--ease-out);
}

.w-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.w-card-glass {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.w-card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 16px;
}

/* Stat cards */
.w-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.w-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.w-stat:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.w-stat-icon svg { width: 22px; height: 22px; fill: currentColor; }

.w-stat-icon.blue { background: var(--info-soft); color: var(--info); }
.w-stat-icon.amber { background: var(--accent-soft); color: var(--accent); }
.w-stat-icon.green { background: var(--success-soft); color: var(--success); }
.w-stat-icon.purple { background: rgba(139,92,246,0.12); color: #a78bfa; }

.w-stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 4px;
}

.w-stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Next event / reminder cards */
.w-next-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.w-next {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
}

.w-next:hover { border-color: var(--border-hover); }

.w-next::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
}

.w-next.event::before { background: var(--accent); }
.w-next.reminder::before { background: var(--info); }

.w-next-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.w-next.event .w-next-label { color: var(--accent); }
.w-next.reminder .w-next-label { color: var(--info); }

.w-next-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  margin-bottom: 6px;
}

.w-next-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Greeting hero */
.w-hero {
  margin-bottom: 32px;
  animation: fadeInUp 0.5s var(--ease-out);
}

.w-hero-greeting {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.w-hero-date {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ─── Calendar agenda (desktop) ─── */
.w-agenda { display: flex; flex-direction: column; gap: 24px; }

.w-agenda-day-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.w-agenda-day-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
}

.w-agenda-day-date {
  font-size: 13px;
  color: var(--text-muted);
}

.w-agenda-event {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-left: 3px solid var(--accent);
  cursor: pointer;
  transition: all 0.15s;
}

.w-agenda-event:hover {
  border-color: var(--border-hover);
  transform: translateX(2px);
}

.w-agenda-event.allday { border-left-color: var(--success); }

.w-agenda-time {
  min-width: 68px;
  flex-shrink: 0;
}

.w-agenda-time-start {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.w-agenda-time-end {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.w-agenda-time.allday {
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.w-agenda-body { flex: 1; min-width: 0; }

.w-agenda-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.w-agenda-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Period toggle */
.w-period-toggle {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
  margin-bottom: 24px;
}

.w-period-btn {
  padding: 7px 18px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.w-period-btn:hover { color: var(--text-primary); }
.w-period-btn.active {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}

/* ─── Buttons ─── */
.w-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}

.w-btn-primary {
  background: var(--accent);
  color: #000;
}

.w-btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.w-btn-secondary {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.w-btn-secondary:hover { border-color: var(--border-hover); color: var(--text-primary); }

/* ─── Empty state ─── */
.w-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.w-empty-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.w-empty-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 6px;
}

.w-empty-sub {
  font-size: 14px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════
   ORG HUB
   ═══════════════════════════════════════════════════════ */
.w-org-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.w-org-card {
  transition: all 0.15s var(--ease-out);
}

.w-org-card:hover {
  border-color: var(--accent);
  transform: translateX(3px);
}

.w-org-badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.w-org-badge.director {
  background: var(--accent-soft);
  color: var(--accent);
}

.w-org-badge.member {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.w-org-member-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.w-org-search-result:hover {
  background: var(--bg-glass-hover);
}

.w-org-notes-content h2,
.w-org-notes-content h3,
.w-org-notes-content h4 {
  font-family: var(--font-display);
  color: var(--text-primary);
}

.w-org-notes-content h2 { font-weight: 700; font-size: 18px; margin: 24px 0 10px; }
.w-org-notes-content h3 { font-weight: 600; font-size: 16px; margin: 20px 0 8px; }
.w-org-notes-content h4 { font-weight: 600; margin: 16px 0 8px; }
.w-org-notes-content strong { font-weight: 600; color: var(--text-primary); }

/* ═══════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.anim-stagger > * {
  animation: fadeInUp 0.5s var(--ease-out) backwards;
}
.anim-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.anim-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.anim-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.anim-stagger > *:nth-child(4) { animation-delay: 0.2s; }
.anim-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.anim-stagger > *:nth-child(6) { animation-delay: 0.3s; }
.anim-stagger > *:nth-child(7) { animation-delay: 0.35s; }
.anim-stagger > *:nth-child(8) { animation-delay: 0.4s; }

/* Page transition */
.main-content > * {
  animation: fadeInUp 0.35s var(--ease-out);
}

/* Skeleton loader */
.w-skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

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

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: var(--sidebar-collapsed) 1fr;
  }
  .sidebar-label, .sidebar-badge, .sidebar-section, .sidebar-logo-text { opacity: 0; width: 0; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-login { min-height: 100vh; }
}

@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main"
      "sidebar";
  }

  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 200;
    background: var(--bg-primary);
  }

  .sidebar-header, .sidebar-section, .sidebar-footer { display: none; }

  .sidebar-nav {
    flex-direction: row;
    padding: 6px;
    justify-content: space-around;
    overflow: visible;
    gap: 0;
  }

  .sidebar-item {
    flex-direction: column;
    gap: 3px;
    padding: 6px 8px;
    font-size: 10px;
    justify-content: center;
    align-items: center;
  }

  .sidebar-item.active::before { display: none; }

  .sidebar-label { opacity: 1 !important; width: auto !important; }
  .sidebar-badge { display: none; }

  .main-content {
    max-height: none;
    padding: 16px;
    padding-bottom: 80px;
  }

  .topbar { padding: 0 16px; }
  .topbar-search { display: none; }

  .w-stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .w-stat { padding: 16px; }
  .w-stat-value { font-size: 22px; }
  .w-next-grid { grid-template-columns: 1fr; }
}

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