/* ── VARIABLES ── */
:root {
  --bg: #0a0e1a; --surface: #111827; --surface2: #1a2235; --border: #1e2d45;
  --text: #f1f5f9; --text2: #94a3b8; --text3: #4a5568;
  --blue: #3b82f6; --green: #10b981; --yellow: #f59e0b; --red: #ef4444; --purple: #8b5cf6;
  --radius: 12px; --radius-sm: 8px;
}
:root.light-mode {
  --bg: #f1f5f9; --surface: #ffffff; --surface2: #e2e8f0; --border: #cbd5e1;
  --text: #0f172a; --text2: #475569; --text3: #94a3b8;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }

/* ── LOGIN ── */
#login-page { display: none; position: fixed; inset: 0; background: var(--bg); z-index: 1000; align-items: center; justify-content: center; flex-direction: column; gap: 24px; }
#login-page.show { display: flex; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: 90%; max-width: 360px; }
.login-logo { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.login-sub { font-size: 11px; color: var(--text3); margin-bottom: 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; color: var(--text2); margin-bottom: 5px; }
.input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text); font-size: 13px; outline: none; transition: border .2s; }
.input:focus { border-color: var(--blue); }
.input-sm { padding: 6px 10px; font-size: 12px; }
.btn-primary { width: 100%; background: var(--blue); color: #fff; border: none; border-radius: var(--radius-sm); padding: 11px; font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity .2s; }
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .5; }
.error-msg { background: #1f0a0a; border: 1px solid var(--red); color: var(--red); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12px; margin-bottom: 12px; }

/* ── APP LAYOUT ── */
#app { display: none; }
#app.show { display: block; }

/* Sidebar */
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 220px; background: var(--surface); border-right: 1px solid var(--border); z-index: 50; display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.sidebar-logo { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; }
.sidebar-brand-text { font-size: 13px; font-weight: 700; line-height: 1.2; }
.sidebar-brand-sub { font-size: 10px; color: var(--text3); font-weight: 400; }
.sidebar-nav { flex: 1; padding: 4px 8px; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; font-size: 12px; font-weight: 500; color: var(--text2); cursor: pointer; transition: all .15s; margin-bottom: 2px; text-decoration: none; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(59,130,246,.15); color: var(--blue); font-weight: 600; }
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); margin-top: auto; }
.sidebar-profile { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; font-size: 12px; color: var(--text2); }
.sidebar-profile .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--blue); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; }

/* Topbar */
.topbar { position: fixed; top: 0; left: 220px; right: 0; height: 42px; background: var(--surface); border-bottom: 1px solid var(--border); z-index: 40; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; gap: 8px; }
.topbar-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.topbar-left .logo { font-size: 13px; font-weight: 800; white-space: nowrap; margin-right: 4px; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.topbar .btn-icon { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 8px; font-size: 11px; cursor: pointer; color: var(--text2); white-space: nowrap; }
.topbar .btn-icon:hover { border-color: var(--blue); color: var(--blue); }

/* Main content */
.main { margin-left: 220px; margin-top: 42px; padding: 20px; min-height: calc(100vh - 42px); }
.page { display: none; }
.page.active { display: block; }
.page-header { margin-bottom: 20px; }
.page-header h2 { font-size: 18px; font-weight: 700; }
.page-header p { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* Loading */
.loading { text-align: center; padding: 40px; color: var(--text3); font-size: 13px; }

/* AI Chat floating button */
.chat-btn { position: fixed; bottom: 24px; right: 24px; width: 48px; height: 48px; border-radius: 50%; background: var(--blue); color: #fff; border: none; cursor: pointer; font-size: 20px; box-shadow: 0 4px 12px rgba(59,130,246,.4); z-index: 100; transition: transform .2s; }
.chat-btn:hover { transform: scale(1.1); }
.chat-panel { position: fixed; bottom: 80px; right: 24px; width: 340px; max-height: 480px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); z-index: 99; display: none; flex-direction: column; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.chat-panel.show { display: flex; }
.chat-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; }
.chat-close { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 16px; }
.chat-body { flex: 1; padding: 12px 16px; overflow-y: auto; max-height: 350px; font-size: 12px; line-height: 1.6; }
.chat-msg { margin-bottom: 10px; padding: 8px 12px; border-radius: 8px; max-width: 85%; }
.chat-msg.user { background: var(--blue); color: #fff; margin-left: auto; }
.chat-msg.bot { background: var(--surface2); color: var(--text); }
.chat-footer { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); }
.chat-footer input { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; color: var(--text); font-size: 12px; outline: none; }
.chat-footer input:focus { border-color: var(--blue); }
.chat-footer button { background: var(--blue); color: #fff; border: none; border-radius: 6px; padding: 8px 14px; cursor: pointer; font-size: 12px; font-weight: 600; }
