:root {
    --primary: #1a1a2e;
    --accent: #e8a020;
    --accent-dark: #c8881a;
    --bg: #f0f2f5;
    --white: #ffffff;
    --text: #2d3748;
    --text-light: #718096;
    --border: #e2e8f0;
    --success: #48bb78;
    --danger: #fc8181;
    --sidebar-w: 240px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* LOGIN */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); }
.login-card { background: var(--white); border-radius: 16px; padding: 48px 40px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { color: var(--primary); font-size: 22px; font-weight: 700; margin-top: 8px; }
.login-logo span { color: var(--accent); }
.login-logo p { color: var(--text-light); font-size: 13px; margin-top: 4px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-group input { width: 100%; padding: 12px 16px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; transition: border-color 0.2s; outline: none; }
.form-group input:focus { border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--white); width: 100%; justify-content: center; font-size: 15px; padding: 14px; }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn-secondary { background: var(--bg); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: #fff5f5; color: #c53030; border: 1px solid #fed7d7; }
.btn-danger:hover { background: #fed7d7; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.error-msg { color: #c53030; font-size: 13px; margin-top: 12px; text-align: center; display: none; }

/* LAYOUT */
.layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar { width: var(--sidebar-w); background: var(--primary); color: var(--white); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
.sidebar-logo { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo h2 { font-size: 16px; font-weight: 700; color: var(--white); }
.sidebar-logo h2 span { color: var(--accent); }
.sidebar-logo p { font-size: 11px; color: rgba(255,255,255,0.5); margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 16px 0; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; color: rgba(255,255,255,0.65); text-decoration: none; font-size: 14px; font-weight: 500; transition: all 0.2s; border-left: 3px solid transparent; }
.nav-item:hover, .nav-item.active { color: var(--white); background: rgba(255,255,255,0.08); border-left-color: var(--accent); }
.nav-item svg { flex-shrink: 0; }
.sidebar-user { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-user p { font-size: 13px; font-weight: 600; color: var(--white); }
.sidebar-user span { font-size: 11px; color: rgba(255,255,255,0.5); }
.sidebar-user .logout-btn { margin-top: 10px; background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7); border: none; padding: 8px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; width: 100%; text-align: left; transition: background 0.2s; }
.sidebar-user .logout-btn:hover { background: rgba(255,255,255,0.15); color: var(--white); }

/* MAIN */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }
.topbar { background: var(--white); border-bottom: 1px solid var(--border); padding: 16px 32px; display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { font-size: 20px; font-weight: 700; }
.content { padding: 32px; flex: 1; }

/* CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 32px; }
.stat-card { background: var(--white); border-radius: 12px; padding: 24px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); border-left: 4px solid var(--accent); }
.stat-card .value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 13px; color: var(--text-light); margin-top: 4px; }
.card { background: var(--white); border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); overflow: hidden; }
.card-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h2 { font-size: 16px; font-weight: 600; }
.card-body { padding: 24px; }

/* TABLE */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-success { background: #f0fff4; color: #276749; }
.badge-gray { background: #f7fafc; color: #718096; border: 1px solid var(--border); }

/* CHAT */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - 65px); }
.chat-messages { flex: 1; overflow-y: auto; padding: 24px 32px; display: flex; flex-direction: column; gap: 20px; }
.message { display: flex; gap: 12px; max-width: 85%; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.message.assistant .message-avatar { background: var(--accent); color: var(--white); }
.message.user .message-avatar { background: var(--primary); color: var(--white); }
.message-bubble { padding: 12px 16px; border-radius: 16px; font-size: 14px; line-height: 1.6; }
.message.assistant .message-bubble { background: var(--white); border: 1px solid var(--border); border-radius: 4px 16px 16px 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.message.user .message-bubble { background: var(--primary); color: var(--white); border-radius: 16px 4px 16px 16px; }
.message-bubble pre { background: #f7fafc; border-radius: 6px; padding: 12px; overflow-x: auto; margin-top: 8px; font-size: 13px; }
.message-bubble h1,.message-bubble h2,.message-bubble h3 { margin: 12px 0 6px; }
.message-bubble ul,.message-bubble ol { padding-left: 20px; margin: 8px 0; }
.message-bubble table { margin: 12px 0; font-size: 13px; }
.message-bubble th,.message-bubble td { padding: 6px 10px; border: 1px solid var(--border); }
.chat-input-area { background: var(--white); border-top: 1px solid var(--border); padding: 16px 32px; }
.chat-input-wrapper { display: flex; gap: 12px; align-items: flex-end; max-width: 900px; margin: 0 auto; }
.chat-input-wrapper textarea { flex: 1; border: 1.5px solid var(--border); border-radius: 12px; padding: 12px 16px; font-size: 14px; font-family: inherit; resize: none; outline: none; max-height: 150px; line-height: 1.5; transition: border-color 0.2s; }
.chat-input-wrapper textarea:focus { border-color: var(--accent); }
.send-btn { background: var(--accent); color: var(--white); border: none; border-radius: 12px; width: 44px; height: 44px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s; flex-shrink: 0; }
.send-btn:hover { background: var(--accent-dark); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.typing { display: flex; align-items: center; gap: 4px; padding: 12px 16px; background: var(--white); border-radius: 16px; border: 1px solid var(--border); width: fit-content; }
.typing span { width: 8px; height: 8px; background: var(--text-light); border-radius: 50%; 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); } }
.welcome-msg { text-align: center; padding: 60px 20px; color: var(--text-light); }
.welcome-msg h3 { font-size: 18px; color: var(--text); margin-bottom: 8px; }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; display: none; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: var(--white); border-radius: 16px; padding: 32px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal h2 { font-size: 18px; margin-bottom: 24px; }
.modal .form-group { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--primary); color: var(--white); padding: 12px 20px; border-radius: 8px; font-size: 14px; z-index: 9999; transform: translateY(100px); transition: transform 0.3s; }
.toast.show { transform: translateY(0); }
