/* ============================================
   NormaHub SaaS – Main Stylesheet
   ============================================ */

/* --- CSS Variables --- */
:root {
  --primary: #5046E5;
  --primary-dark: #4138C9;
  --primary-light: #736CF2;
  --accent: #FF6584;
  --bg: #F7F8FC;
  --bg-sidebar: #1E1E2D;
  --bg-sidebar-hover: #2A2A3C;
  --bg-card: #FFFFFF;
  --text: #2D3748;
  --text-light: #718096;
  --text-sidebar: #A2A3B7;
  --text-sidebar-active: #FFFFFF;
  --border: #E2E8F0;
  --success: #48BB78;
  --warning: #ED8936;
  --danger: #F56565;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --transition: 0.25s cubic-bezier(.4,0,.2,1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; display: block; }
input, select, textarea { font-family: inherit; }

/* --- Utility --- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.text-center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  border: none; transition: var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(80,70,229,.3); }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-white { background: #fff; color: var(--primary); }
.btn-white:hover { background: #f0f0ff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #E53E3E; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #38A169; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-lg { padding: 16px 32px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* --- Input --- */
.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.input-field {
  width: 100%; padding: 12px 16px;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; background: #fff; color: var(--text);
  transition: var(--transition);
}
.input-field:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(80,70,229,.1); }
.input-field::placeholder { color: var(--text-light); }

/* --- Cards --- */
.card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
}

/* --- Badge --- */
.badge {
  display: inline-flex; align-items: center; padding: 4px 10px;
  border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-primary { background: rgba(80,70,229,.1); color: var(--primary); }
.badge-success { background: rgba(72,187,120,.1); color: var(--success); }
.badge-warning { background: rgba(237,137,54,.1); color: var(--warning); }
.badge-danger { background: rgba(245,101,101,.1); color: var(--danger); }
.badge-secondary { background: rgba(160,160,160,.1); color: #777; }

/* ============================================
   LANDING PAGE
   ============================================ */

/* Navbar */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(255,255,255,.95); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 72px;
  display: flex; align-items: center;
}
.navbar .container { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.navbar-brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; color: var(--primary); }
.navbar-brand svg { width: 32px; height: 32px; }
.navbar-links { display: flex; gap: 32px; align-items: center; }
.navbar-links a { font-size: 14px; font-weight: 500; color: var(--text-light); transition: var(--transition); }
.navbar-links a:hover { color: var(--primary); }
.navbar-actions { display: flex; gap: 12px; align-items: center; }

/* Hero */
.hero {
  padding: 160px 0 100px;
  background: linear-gradient(160deg, #f0efff 0%, #fff 50%, #fff5f7 100%);
  position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; top: -50%; right: -20%;
  width: 600px; height: 600px; border-radius: 50%;
  background: radial-gradient(circle, rgba(80,70,229,.08), transparent 70%);
}
.hero .container { position: relative; z-index: 1; display: flex; align-items: center; gap: 60px; }
.hero-text { flex: 1; }
.hero-text h1 { font-size: 52px; font-weight: 800; line-height: 1.15; margin-bottom: 24px; color: #1a1a2e; }
.hero-text h1 span { color: var(--primary); }
.hero-text p { font-size: 18px; color: var(--text-light); margin-bottom: 36px; max-width: 520px; }
.hero-actions { display: flex; gap: 16px; }
.hero-visual { flex: 1; display: flex; justify-content: center; }
.hero-card {
  background: var(--bg-card); border-radius: 16px; padding: 32px;
  box-shadow: var(--shadow-lg); width: 400px; transform: rotate(2deg);
}
.hero-card .fake-search { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--bg); border-radius: var(--radius-sm); margin-bottom: 20px; }
.hero-card .fake-search span { color: var(--text-light); font-size: 14px; }
.hero-card .fake-result { padding: 12px; background: var(--bg); border-radius: var(--radius-sm); margin-bottom: 10px; border-left: 3px solid var(--primary); }
.hero-card .fake-result .title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.hero-card .fake-result .text { font-size: 12px; color: var(--text-light); }

/* Features */
.features { padding: 100px 0; }
.section-title { text-align: center; margin-bottom: 60px; }
.section-title h2 { font-size: 36px; font-weight: 700; margin-bottom: 16px; }
.section-title p { font-size: 16px; color: var(--text-light); max-width: 600px; margin: 0 auto; }
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.feature-card { padding: 32px; border-radius: var(--radius); background: var(--bg-card); box-shadow: var(--shadow); transition: var(--transition); }
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.feature-icon { width: 56px; height: 56px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 20px; font-size: 24px; }
.feature-icon.purple { background: rgba(80,70,229,.1); color: var(--primary); }
.feature-icon.pink { background: rgba(255,101,132,.1); color: var(--accent); }
.feature-icon.green { background: rgba(72,187,120,.1); color: var(--success); }
.feature-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.feature-card p { font-size: 14px; color: var(--text-light); line-height: 1.7; }

/* Pricing */
.pricing { padding: 100px 0; background: linear-gradient(180deg, #fff 0%, var(--bg) 100%); }
.pricing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; max-width: 960px; margin: 0 auto; }
.pricing-card { padding: 40px 32px; border-radius: var(--radius); background: var(--bg-card); box-shadow: var(--shadow); text-align: center; transition: var(--transition); position: relative; }
.pricing-card.popular { border: 2px solid var(--primary); transform: scale(1.05); }
.pricing-card.popular::before {
  content: 'Популярный'; position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff; padding: 4px 20px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.pricing-card h3 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.pricing-card .price { font-size: 42px; font-weight: 800; color: var(--primary); margin: 20px 0; }
.pricing-card .price span { font-size: 16px; font-weight: 400; color: var(--text-light); }
.pricing-card ul { list-style: none; margin: 24px 0; text-align: left; }
.pricing-card ul li { padding: 8px 0; font-size: 14px; color: var(--text); display: flex; align-items: center; gap: 10px; }
.pricing-card ul li::before { content: '✓'; color: var(--success); font-weight: 700; }
.pricing-card .btn { width: 100%; }

/* Footer */
.footer { padding: 60px 0 30px; background: var(--bg-sidebar); color: var(--text-sidebar); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 60px; margin-bottom: 40px; }
.footer-brand { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 12px; }
.footer-desc { font-size: 14px; line-height: 1.7; }
.footer h4 { font-size: 14px; font-weight: 600; color: #fff; margin-bottom: 16px; text-transform: uppercase; letter-spacing: 1px; }
.footer ul { list-style: none; }
.footer ul li { margin-bottom: 10px; }
.footer ul a { font-size: 14px; transition: var(--transition); }
.footer ul a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); padding-top: 24px; font-size: 13px; text-align: center; }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 40px;
  width: 100%; max-width: 440px; position: relative;
  animation: modalSlideIn .3s ease;
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text-light); transition: var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal h2 { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.modal .subtitle { font-size: 14px; color: var(--text-light); margin-bottom: 28px; }
.modal .input-group { margin-bottom: 20px; }
.modal .form-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; }
.modal .form-footer a { font-size: 13px; color: var(--primary); font-weight: 500; }
.modal .form-footer a:hover { text-decoration: underline; }
.modal .divider { text-align: center; margin: 20px 0; font-size: 13px; color: var(--text-light); position: relative; }
.modal .divider::before, .modal .divider::after { content: ''; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--border); }
.modal .divider::before { left: 0; }
.modal .divider::after { right: 0; }
.modal .error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; display: none; }
.modal .error-msg.visible { display: block; }
.modal .tab-switch { display: flex; margin-bottom: 24px; border-bottom: 2px solid var(--border); }
.modal .tab-switch button {
  flex: 1; padding: 12px; border: none; background: none;
  font-size: 14px; font-weight: 600; color: var(--text-light);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: var(--transition);
}
.modal .tab-switch button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ============================================
   DASHBOARD LAYOUT (User + Admin)
   ============================================ */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: 260px; background: var(--bg-sidebar); color: var(--text-sidebar);
  display: flex; flex-direction: column; flex-shrink: 0;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
}
.sidebar-brand {
  padding: 24px; display: flex; align-items: center; gap: 12px;
  font-size: 18px; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-section { margin-bottom: 24px; }
.sidebar-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; padding: 0 12px; margin-bottom: 8px; color: rgba(255,255,255,.3); }
.sidebar-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  color: var(--text-sidebar); transition: var(--transition); cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
}
.sidebar-link:hover { background: var(--bg-sidebar-hover); color: #fff; }
.sidebar-link.active { background: var(--primary); color: #fff; }
.sidebar-link .icon { width: 20px; text-align: center; font-size: 16px; }
/* Admin back-to-panel button */
.admin-back-btn {
  background: rgba(99, 102, 241, .15); border: 1px solid rgba(99, 102, 241, .35);
  color: #a5b4fc; text-decoration: none;
}
.admin-back-btn:hover { background: rgba(99, 102, 241, .30); color: #fff; }
.sidebar-link .badge-count {
  margin-left: auto; background: var(--accent); color: #fff;
  padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600;
}
.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-user { display: flex; align-items: center; gap: 12px; padding: 8px 12px; }
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff; display: flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.sidebar-user-info .name { font-size: 13px; font-weight: 600; color: #fff; }
.sidebar-user-info .role { font-size: 11px; color: var(--text-sidebar); }

/* Main content */
.main-content { flex: 1; margin-left: 260px; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar {
  height: 64px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; flex-shrink: 0;
}
.topbar h2 { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.page-content { flex: 1; padding: 32px; overflow-y: auto; min-height: 0; }

/* Documents panel: scroll lives inside the table card */
#panelDocuments > .page-content { display: flex; flex-direction: column; overflow: hidden; }
#docTableWrap { flex: 1; min-height: 0; overflow-y: auto; border-radius: var(--radius); }

/* Panels – show/hide */
.panel { display: none; }
.panel.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ============================================
   CHAT PANEL
   ============================================ */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - 64px - 64px); }
.chat-messages { flex: 1; overflow-y: auto; padding: 24px; }
.chat-message { display: flex; gap: 12px; margin-bottom: 20px; max-width: 80%; }
.chat-message.user { margin-left: auto; flex-direction: row-reverse; }
.chat-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.chat-message.bot .chat-avatar { background: rgba(80,70,229,.1); color: var(--primary); }
.chat-message.user .chat-avatar { background: var(--primary); color: #fff; }
.chat-bubble {
  padding: 14px 18px; border-radius: 16px; font-size: 14px; line-height: 1.6;
}
.chat-message.bot .chat-bubble { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.06); border-bottom-left-radius: 4px; }
.chat-message.user .chat-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-source {
  margin-top: 8px; padding: 10px 14px; background: var(--bg);
  border-radius: var(--radius-sm); border-left: 3px solid var(--primary);
  font-size: 12px; color: var(--text-light);
}
.chat-source .source-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.chat-input-area {
  padding: 16px 24px; background: #fff; border-top: 1px solid var(--border);
  display: flex; gap: 12px; align-items: flex-end;
}
.chat-input-area .input-wrap { flex: 1; position: relative; }
.chat-input-area textarea {
  width: 100%; padding: 14px 16px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; resize: none;
  min-height: 48px; max-height: 120px; background: var(--bg);
  transition: var(--transition); font-family: var(--font);
}
.chat-input-area textarea:focus { outline: none; border-color: var(--primary); background: #fff; }
.chat-send-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition); flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--primary-dark); transform: scale(1.05); }
.chat-send-btn:disabled { opacity: .4; }

/* Filter row inside chat */
.chat-filters { padding: 0 24px 8px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.chat-filters select {
  padding: 8px 12px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; background: #fff;
}
#searchFilters { display: flex; gap: 12px; align-items: center; }
.deep-search-hint {
  font-size: 0.85rem; color: var(--text-light);
  display: none;
}
.scope-info {
  font-size: 12px; color: var(--text-light);
  border: 1px solid var(--border); border-radius: 50%;
  width: 18px; height: 18px; display: inline-flex;
  align-items: center; justify-content: center;
  background: #fff; line-height: 1;
}

/* Mode toggle */
.mode-toggle {
  display: flex; gap: 4px; background: var(--bg-card); border: 2px solid var(--border);
  border-radius: var(--radius-sm); padding: 3px; flex-shrink: 0;
}
.mode-btn {
  display: flex; align-items: center; gap: 6px; padding: 6px 14px;
  border: none; background: transparent; border-radius: calc(var(--radius-sm) - 2px);
  font-size: 13px; font-weight: 500; color: var(--text-light); cursor: pointer;
  transition: var(--transition);
}
.mode-btn:hover { color: var(--text); background: rgba(0,0,0,.04); }
.mode-btn.active {
  background: var(--primary); color: #fff; box-shadow: 0 1px 3px rgba(79,70,229,.3);
}

/* Chat content wrapper */
.chat-content { flex: 1; min-width: 0; }

/* Chat metadata (model, duration) */
.chat-meta {
  font-size: 11px; color: var(--text-light); margin-top: 4px; padding-left: 2px;
}

/* Streaming animation */
.chat-streaming::after {
  content: ''; display: inline-block; width: 6px; height: 16px;
  background: var(--primary); margin-left: 2px; vertical-align: text-bottom;
  animation: blink-cursor .7s step-end infinite;
}
@keyframes blink-cursor { 50% { opacity: 0; } }

/* Markdown in chat bubbles */
.chat-bubble code {
  background: rgba(79,70,229,.08); padding: 1px 5px; border-radius: 3px;
  font-size: .9em; font-family: 'JetBrains Mono', monospace;
}
.chat-bubble pre {
  background: #1e1e2e; color: #cdd6f4; padding: 12px 16px; border-radius: 8px;
  overflow-x: auto; margin: 8px 0; font-size: .85em; line-height: 1.5;
}
.chat-bubble pre code { background: none; padding: 0; color: inherit; }

/* Message action buttons (copy, edit, thumbs) */
.msg-actions {
  display: flex; gap: 4px; margin-top: 6px; opacity: 0;
  transition: opacity .2s ease;
}
.chat-message:hover .msg-actions { opacity: 1; }
.msg-actions[data-rated] { opacity: 1; } /* keep visible after rating */
.msg-action-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 8px; font-size: 14px; cursor: pointer; color: var(--text-light);
  transition: all .15s ease; line-height: 1.4;
}
.msg-action-btn:hover { background: var(--bg-light); border-color: var(--primary); color: var(--primary); }
.thumb-active { background: rgba(80,70,229,.12) !important; border-color: var(--primary) !important; color: var(--primary) !important; transform: scale(1.15); }
.thumb-dimmed { opacity: .35; pointer-events: none; }
.chat-message.user .msg-actions { justify-content: flex-end; }

/* ============================================
   HISTORY PANEL
   ============================================ */
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: pointer; transition: var(--transition);
}
.history-item:hover { transform: translateX(4px); box-shadow: var(--shadow-lg); }
.history-query { font-size: 14px; font-weight: 500; }
.history-meta { font-size: 12px; color: var(--text-light); }

/* ============================================
   SETTINGS PANEL
   ============================================ */
.settings-section { margin-bottom: 32px; }
.settings-section h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.settings-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; }
.settings-row label { font-size: 14px; }
.toggle {
  width: 48px; height: 26px; border-radius: 13px; background: var(--border);
  position: relative; cursor: pointer; transition: var(--transition);
}
.toggle.active { background: var(--primary); }
.toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: var(--transition); box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle.active::after { left: 25px; }

/* ============================================
   PERSONALITY CARDS (settings)
   ============================================ */
.personality-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}
.personality-card {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 16px 12px; border-radius: 12px; cursor: pointer;
    border: 2px solid var(--border); background: var(--white);
    transition: var(--transition); text-align: center;
}
.personality-card:hover { border-color: var(--primary); background: #f5f3ff; }
.personality-card.active { border-color: var(--primary); background: #ede9fe; box-shadow: 0 0 0 3px rgba(80,70,229,.15); }
.personality-card .p-icon { font-size: 28px; }
.personality-card .p-label { font-size: 13px; font-weight: 600; color: var(--text); }

/* Quick personality selector (chat toolbar) */
.personality-indicator { margin-left: auto; display: flex; align-items: center; }
.personality-select {
    font-size: 0.82rem; padding: 4px 8px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--white);
    color: var(--text); cursor: pointer; outline: none;
    transition: var(--transition);
}
.personality-select:hover { border-color: var(--primary); }
.personality-select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(80,70,229,.15); }

/* ============================================
   BILLING / TARIFFS PANEL
   ============================================ */
.current-plan { padding: 24px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; border-radius: var(--radius); margin-bottom: 32px; }
.current-plan h3 { font-size: 14px; opacity: .8; }
.current-plan .plan-name { font-size: 28px; font-weight: 800; margin: 8px 0; }
.current-plan .plan-details { font-size: 14px; opacity: .9; }
.tariff-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 20px; }
.tariff-card {
  padding: 28px; background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow);
  text-align: center; border: 2px solid transparent; transition: var(--transition);
}
.tariff-card:hover { border-color: var(--primary); }
.tariff-card.active-plan { border-color: var(--primary); }
.tariff-card h4 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.tariff-card .tariff-price { font-size: 32px; font-weight: 800; color: var(--primary); margin: 12px 0; }
.tariff-card .tariff-price span { font-size: 14px; font-weight: 400; color: var(--text-light); }
.tariff-card ul { list-style: none; margin: 16px 0; text-align: left; }
.tariff-card ul li { padding: 6px 0; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.tariff-card ul li::before { content: '✓'; color: var(--success); font-weight: 700; font-size: 14px; }

/* ============================================
   ADMIN – Documents
   ============================================ */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 48px; text-align: center; transition: var(--transition); cursor: pointer;
  background: var(--bg); margin-bottom: 24px;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: rgba(80,70,229,.03); }
.upload-zone .icon { font-size: 48px; margin-bottom: 12px; }
.upload-zone h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.upload-zone p { font-size: 13px; color: var(--text-light); }
.upload-zone input[type="file"] { display: none; }
.upload-file-list { margin-bottom: 20px; }
.upload-file-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--bg); border-radius: var(--radius-sm);
  margin-bottom: 8px; font-size: 13px;
}
.upload-file-item .file-name { font-weight: 500; }
.upload-file-item .file-size { color: var(--text-light); }
.upload-file-item .remove-file { color: var(--danger); cursor: pointer; background: none; border: none; font-size: 16px; }

/* Progress bar */
.progress-bar { width: 100%; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 12px; }
.progress-bar .fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .5s ease; }

/* Pipeline Steps */
.pipeline-steps { display: flex; flex-direction: column; gap: 0; }
.pipeline-step {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-left: 3px solid var(--border);
  transition: var(--transition); position: relative;
}
.pipeline-step .step-icon { font-size: 20px; flex-shrink: 0; filter: grayscale(0.7); opacity: 0.5; transition: var(--transition); }
.pipeline-step .step-body { flex: 1; min-width: 0; }
.pipeline-step .step-label { font-size: 13px; font-weight: 600; color: var(--text-light); transition: var(--transition); }
.pipeline-step .step-detail { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.pipeline-step .step-status { flex-shrink: 0; width: 24px; text-align: center; }

.pipeline-step.active { border-left-color: var(--primary); background: rgba(80,70,229,.04); }
.pipeline-step.active .step-icon { filter: none; opacity: 1; }
.pipeline-step.active .step-label { color: var(--primary); }
.pipeline-step.done { border-left-color: var(--success); }
.pipeline-step.done .step-icon { filter: none; opacity: 1; }
.pipeline-step.done .step-label { color: var(--success); }
.pipeline-step.error { border-left-color: var(--danger); }
.pipeline-step.error .step-icon { filter: none; opacity: 1; }
.pipeline-step.error .step-label { color: var(--danger); }

/* Spinner */
.spinner-sm {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Per-file status rows */
.file-status-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  font-size: 12px; margin-bottom: 4px; transition: var(--transition);
}
.file-status-row .fsr-icon { flex-shrink: 0; font-size: 14px; }
.file-status-row .fsr-name { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-status-row .fsr-badge {
  flex-shrink: 0; font-size: 11px; padding: 2px 8px;
  border-radius: 10px; font-weight: 600;
}
.fst-ready { background: rgba(72,187,120,.08); }
.fst-ready .fsr-badge { background: rgba(72,187,120,.15); color: var(--success); }
.fst-indexing { background: rgba(80,70,229,.05); }
.fst-indexing .fsr-badge { background: rgba(80,70,229,.12); color: var(--primary); }
.fst-pending { background: rgba(237,137,54,.06); }
.fst-pending .fsr-badge { background: rgba(237,137,54,.15); color: var(--warning); }
.fst-error { background: rgba(245,101,101,.06); }
.fst-error .fsr-badge { background: rgba(245,101,101,.15); color: var(--danger); }
.file-status-indicator { margin-left: auto; margin-right: 8px; }

/* Doc table */
.doc-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.doc-table th, .doc-table td { padding: 14px 16px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
.doc-table thead th {
  position: sticky; top: 0; z-index: 9;
  background: var(--bg-card);
  font-weight: 600; color: var(--text-light); font-size: 12px;
  text-transform: uppercase; letter-spacing: .5px;
}
.doc-table th.sortable { cursor: pointer; user-select: none; transition: color .15s; }
.doc-table th.sortable:hover { color: var(--primary); }
.doc-table th .sort-arrow { display: inline-block; margin-left: 4px; font-size: 10px; opacity: .3; transition: opacity .15s; }
.doc-table th.sort-active .sort-arrow { opacity: 1; color: var(--primary); }
.doc-table tr:hover td { background: var(--bg); }
.doc-table .actions { display: flex; gap: 8px; }

/* ============================================
   ADMIN – Stats
   ============================================ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 32px; }
.stat-card {
  padding: 24px; background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 16px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.stat-card .stat-label { font-size: 13px; color: var(--text-light); }

/* Users table */
.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td { padding: 14px 16px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
.users-table th { font-weight: 600; color: var(--text-light); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

/* ============================================
   SPINNER
   ============================================ */
.spinner { border: 3px solid var(--border); border-top: 3px solid var(--primary); border-radius: 50%; width: 24px; height: 24px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-lg { width: 40px; height: 40px; }

/* ============================================
   TOAST
   ============================================ */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 14px 20px; border-radius: var(--radius-sm); color: #fff;
  font-size: 14px; font-weight: 500; min-width: 280px;
  animation: toastIn .3s ease; box-shadow: var(--shadow-lg);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* Inline message next to buttons */
.inline-note {
  display: inline-flex; align-items: center; margin-left: 10px; padding: 6px 10px;
  border-radius: var(--radius-sm); background: #fff; color: #111;
  border: 1px solid var(--border); font-size: 12px; font-weight: 600;
  box-shadow: var(--shadow); vertical-align: middle; max-width: 320px;
  white-space: normal; line-height: 1.3;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  .features-grid, .pricing-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .hero .container { flex-direction: column; text-align: center; }
  .hero-text h1 { font-size: 36px; }
  .hero-text p { margin: 0 auto 36px; }
  .hero-actions { justify-content: center; }
  .hero-visual { display: none; }
  .features-grid, .pricing-grid { grid-template-columns: 1fr; }
  .pricing-card.popular { transform: none; }
  .navbar-links { display: none; }
  .sidebar { width: 72px; }
  .sidebar-brand span, .sidebar-section-title, .sidebar-link span:not(.icon), .sidebar-user-info, .sidebar-link .badge-count { display: none; }
  .sidebar-link { justify-content: center; padding: 12px; }
  .main-content { margin-left: 72px; }
  .topbar { flex-direction: column; align-items: flex-start; height: auto; gap: 8px; padding: 12px 20px; }
  .topbar-right { flex-wrap: wrap; gap: 8px; }
  .mode-toggle { flex-wrap: wrap; }
  .chat-filters { align-items: flex-start; }
  .footer-grid { grid-template-columns: 1fr; gap: 32px; }
  .stats-grid { grid-template-columns: 1fr; }
  .inline-note { display: block; margin-left: 0; margin-top: 8px; max-width: 100%; }
}
