:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --error: #dc2626;
  --success: #16a34a;
  --sidebar-bg: #0f172a;
  --sidebar-text: #e2e8f0;
  --bubble-user: #2563eb;
  --bubble-ai: #f1f5f9;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--text); background: var(--surface-2); }

/* AUTH */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%); }
.auth-container { width: 100%; max-width: 420px; padding: 20px; }
.auth-card { background: var(--surface); border-radius: 20px; padding: 40px; box-shadow: var(--shadow); }
.logo-area { text-align: center; margin-bottom: 32px; }
.logo-icon { width: 64px; height: 64px; border-radius: 16px; background: var(--primary); color: white; font-size: 22px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.logo-area h1 { font-size: 26px; font-weight: 700; color: var(--text); }
.tagline { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input { width: 100%; padding: 12px 16px; border: 2px solid var(--border); border-radius: 10px; font-size: 15px; transition: border-color 0.2s; outline: none; background: var(--surface); }
.form-group input:focus { border-color: var(--primary); background: var(--primary-light); }
.hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: block; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 60px; }
.toggle-pw { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--primary); font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-primary { width: 100%; padding: 14px; background: var(--primary); color: white; border: none; border-radius: 10px; font-size: 16px; font-weight: 700; cursor: pointer; transition: background 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; }
.error-msg { background: #fef2f2; color: var(--error); padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; border: 1px solid #fecaca; }
.auth-footer { text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 24px; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.4); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* CHAT LAYOUT */
.chat-body { height: 100vh; overflow: hidden; }
.chat-layout { display: flex; height: 100vh; }

/* SIDEBAR */
.sidebar { width: 240px; background: var(--sidebar-bg); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 20px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.logo-sm { width: 36px; height: 36px; background: var(--primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; color: white; flex-shrink: 0; }
.sidebar-header span { color: var(--sidebar-text); font-weight: 700; font-size: 16px; }
.user-info { padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.user-email { color: #94a3b8; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-company { color: var(--primary); font-size: 13px; font-weight: 600; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-label { color: #64748b; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; padding: 0 4px; }
.quick-btn { display: block; width: 100%; text-align: left; padding: 9px 12px; background: transparent; color: #94a3b8; border: none; border-radius: 8px; font-size: 13px; cursor: pointer; transition: all 0.15s; margin-bottom: 2px; }
.quick-btn:hover { background: rgba(255,255,255,0.08); color: var(--sidebar-text); }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.btn-logout { width: 100%; padding: 10px; background: rgba(255,255,255,0.06); color: #94a3b8; border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; font-size: 13px; cursor: pointer; transition: all 0.15s; }
.btn-logout:hover { background: rgba(220,38,38,0.2); color: #fca5a5; border-color: rgba(220,38,38,0.3); }

/* CHAT MAIN */
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); }
.chat-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: var(--surface); }
.chat-header-info { display: flex; align-items: center; gap: 10px; }
.chat-header-info h2 { font-size: 16px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }
.status-text { color: var(--text-muted); font-size: 13px; }
.btn-clear { padding: 6px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; cursor: pointer; color: var(--text-muted); }
.btn-clear:hover { background: var(--border); }

/* MESSAGES */
.chat-messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.message { display: flex; gap: 10px; max-width: 80%; }
.user-message { align-self: flex-end; flex-direction: row-reverse; }
.assistant-message { align-self: flex-start; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; flex-shrink: 0; margin-top: 2px; }
.bubble { padding: 12px 16px; border-radius: 14px; font-size: 14px; line-height: 1.6; }
.user-message .bubble { background: var(--bubble-user); color: white; border-bottom-right-radius: 4px; }
.assistant-message .bubble { background: var(--bubble-ai); color: var(--text); border-bottom-left-radius: 4px; }
.bubble ul { margin: 8px 0 8px 20px; }
.bubble li { margin-bottom: 4px; }
.bubble p { margin-bottom: 6px; }
.bubble p:last-child { margin-bottom: 0; }

/* TYPING */
.typing { display: flex; align-items: center; gap: 4px; padding: 14px 18px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); display: inline-block; animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

/* CLARIFY BAR */
.clarify-bar { padding: 12px 20px; background: #fffbeb; border-top: 1px solid #fde68a; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.clarify-text { font-size: 13px; color: #92400e; flex: 1; }
.clarify-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-draft { padding: 8px 14px; background: #f59e0b; color: white; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-cancel-clarify { padding: 8px 14px; background: transparent; color: #92400e; border: 1px solid #fde68a; border-radius: 8px; font-size: 13px; cursor: pointer; }

/* INPUT AREA */
.chat-input-area { padding: 16px 24px 20px; border-top: 1px solid var(--border); background: var(--surface); }
.input-wrap { display: flex; gap: 10px; align-items: flex-end; }
.input-wrap textarea { flex: 1; padding: 12px 16px; border: 2px solid var(--border); border-radius: 12px; font-size: 14px; resize: none; outline: none; font-family: inherit; line-height: 1.5; max-height: 120px; transition: border-color 0.2s; }
.input-wrap textarea:focus { border-color: var(--primary); }
.send-btn { width: 44px; height: 44px; background: var(--primary); border: none; border-radius: 12px; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.2s; }
.send-btn:hover { background: var(--primary-dark); }
.input-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; text-align: center; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* RESPONSIVE */
@media (max-width: 640px) {
  .sidebar { display: none; }
  .message { max-width: 95%; }
}
