* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
body { background: #f1f5f9; color: #1e293b; font-size: 13px; line-height: 1.4; }
.hidden { display: none !important; }

/* BẢNG TÔNG MÀU TÙY CHỈNH */
body.theme-emerald { background: #ecfdf5; }
body.theme-emerald .top-bar { background: linear-gradient(90deg, #064e3b, #047857); border-bottom-color: #10b981; }
body.theme-royal { background: #fef2f2; }
body.theme-royal .top-bar { background: linear-gradient(90deg, #450a0a, #7f1d1d); border-bottom-color: #f59e0b; }
body.theme-dark { background: #0f172a; color: #e2e8f0; }
body.theme-dark .panel, body.theme-dark .sub-box, body.theme-dark .modal-card { background: #1e293b; border-color: #334155; color: #f1f5f9; }
body.theme-dark input, body.theme-dark select, body.theme-dark textarea { background: #0f172a; color: #f8fafc; border-color: #475569; }
body.theme-dark .cung-cell { background: #1e293b; color: #f1f5f9; }
body.theme-dark .thien-ban-center { background: #0f172a; color: #e2e8f0; }

/* MÀN HÌNH ĐĂNG NHẬP */
.auth-overlay { position: fixed; inset: 0; background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px; }
.auth-card { background: #fff; width: 420px; max-width: 100%; border-radius: 12px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,0.4); }
.auth-header { text-align: center; margin-bottom: 18px; }
.auth-header h1 { color: #991b1b; font-size: 22px; letter-spacing: 0.5px; }
.auth-header p { color: #64748b; font-size: 12px; margin-top: 4px; }
.auth-tabs { display: flex; border-bottom: 2px solid #e2e8f0; margin-bottom: 16px; }
.auth-tab { flex: 1; padding: 10px; border: none; background: none; font-weight: 600; color: #64748b; cursor: pointer; }
.auth-tab.active { color: #1d4ed8; border-bottom: 3px solid #1d4ed8; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 4px; }
.form-group input, .form-group select { width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; }

/* NÚT BẤM */
.btn { padding: 8px 14px; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 12.5px; transition: 0.15s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-sm { padding: 4px 8px; font-size: 11.5px; }
.btn-full { width: 100%; }
.btn-large { padding: 12px; font-size: 14px; margin-top: 8px; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-success { background: #16a34a; color: #fff; }
.btn-info { background: #0284c7; color: #fff; }
.btn-warning { background: #d97706; color: #fff; }
.btn-outline { background: #fff; border: 1px solid #cbd5e1; color: #334155; }

/* THANH TIÊU ĐỀ TRÊN */
.top-bar { background: linear-gradient(90deg, #1e293b, #0f172a); color: #fff; padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; border-bottom: 3px solid #eab308; }
.brand-title { display: flex; align-items: center; gap: 12px; }
.badge-logo { background: #eab308; color: #0f172a; font-size: 20px; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; }
.brand-title h2 { font-size: 17px; color: #fde047; }
.brand-title small { color: #cbd5e1; font-size: 11.5px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-badge { background: rgba(255,255,255,0.12); padding: 5px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; color: #fde047; }

/* BỐ CỤC 3 CỘT */
.workspace-grid { display: grid; grid-template-columns: 360px 1fr 370px; gap: 14px; padding: 14px; max-width: 1700px; margin: 0 auto; }
@media (max-width: 1280px) { .workspace-grid { grid-template-columns: 1fr; } }

.panel { background: #fff; border-radius: 10px; border: 1px solid #cbd5e1; box-shadow: 0 2px 8px rgba(0,0,0,0.05); overflow: hidden; }
.panel-header { padding: 10px 14px; color: #fff; }
.panel-header h3 { font-size: 13px; letter-spacing: 0.3px; }
.header-gold { background: linear-gradient(90deg, #b45309, #d97706); }
.header-red { background: linear-gradient(90deg, #991b1b, #b91c1c); }
.header-blue { background: linear-gradient(90deg, #1e40af, #2563eb); }
.panel-body { padding: 12px; display: flex; flex-direction: column; gap: 12px; }

/* KHỐI NHẬP LIỆU & ĐỔI MÀU THÔNG MINH */
.sub-box { border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px; background: #f8fafc; }
.sub-title { font-size: 11.5px; font-weight: 700; color: #475569; margin-bottom: 8px; border-bottom: 1px dashed #cbd5e1; padding-bottom: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.input-row { margin-bottom: 6px; }
.input-row label { display: block; font-size: 11.5px; font-weight: 600; color: #334155; margin-bottom: 3px; }

.smart-input { width: 100%; padding: 7px 9px; border: 1.5px solid #f59e0b; background-color: #fef9c3; border-radius: 5px; font-size: 12.5px; font-weight: 600; color: #1e293b; transition: 0.2s; }
.smart-input.filled { border-color: #cbd5e1; background-color: #ffffff; font-weight: 500; }
.smart-input.invalid { border-color: #dc2626; background-color: #fee2e2; }
.error-msg { color: #dc2626; font-size: 11.5px; font-weight: 600; background: #fef2f2; padding: 5px 8px; border-radius: 4px; border-left: 3px solid #dc2626; margin-bottom: 6px; }
.auto-result-bar { background: #e0f2fe; color: #0369a1; padding: 6px 8px; border-radius: 5px; font-size: 11.5px; font-weight: 600; margin-top: 4px; }

/* 6 Ô DỮ LIỆU NGẦM TÂM LÝ */
.grid-6o { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.o-mau-item { padding: 6px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.1); }
.o-mau-item label { display: block; font-size: 10.5px; font-weight: 700; margin-bottom: 3px; }
.o-mau-item input { width: 100%; padding: 5px 7px; border: 1px solid rgba(0,0,0,0.18); border-radius: 4px; font-size: 12px; background: rgba(255,255,255,0.88); }
.mau-kim { background: #f1f5f9; }
.mau-moc { background: #dcfce7; }
.mau-thuy { background: #dbeafe; }
.mau-hoa { background: #fee2e2; }
.mau-tho { background: #fef3c7; }
.mau-thaicuc { background: #f3e8ff; }

/* BẢN ĐỒ 12 CUNG TỬ VI (LƯỚI 4x4) */
.laso-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, minmax(158px, auto)); gap: 4px; background: #94a3b8; padding: 4px; border-radius: 8px; }
.thien-ban-center { grid-column: 2 / 4; grid-row: 2 / 4; background: #fffbeb; padding: 14px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; border: 2px solid #f59e0b; border-radius: 4px; }
.thien-ban-center h4 { color: #991b1b; font-size: 16px; margin-bottom: 6px; }
.tb-info-grid { width: 100%; text-align: left; font-size: 12px; display: grid; grid-template-columns: 1fr; gap: 4px; background: #fff; padding: 8px 10px; border-radius: 6px; border: 1px solid #fde68a; }

.cung-cell { background: #fff; padding: 6px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; transition: 0.15s; border: 2px solid transparent; position: relative; }
.cung-cell:hover { background: #f8fafc; }
.cung-cell.active-cung { border-color: #2563eb; background: #eff6ff; box-shadow: inset 0 0 0 1px #2563eb; }
.cung-top { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 3px; margin-bottom: 4px; }
.cung-name-tag { font-weight: 800; font-size: 11px; text-transform: uppercase; color: #1e293b; }
.cung-score-pill { font-size: 10.5px; font-weight: 700; padding: 1px 5px; border-radius: 10px; }
.score-cat { background: #dcfce7; color: #15803d; }
.score-binh { background: #fef9c3; color: #a16207; }
.score-hung { background: #fee2e2; color: #b91c1c; }

.cung-chinh { text-align: center; font-weight: 800; font-size: 12px; margin: 2px 0 4px; min-height: 28px; }
.cung-stars { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; font-size: 10.5px; flex: 1; }
.stars-tot { color: #15803d; font-weight: 600; }
.stars-xau { color: #b91c1c; text-align: right; }

.nh-kim { color: #64748b; }
.nh-moc { color: #16a34a; }
.nh-thuy { color: #2563eb; }
.nh-hoa { color: #dc2626; }
.nh-tho { color: #d97706; }

.cung-bottom { display: flex; justify-content: space-between; align-items: center; border-top: 1px dashed #cbd5e1; padding-top: 3px; margin-top: 4px; font-size: 10px; color: #475569; font-weight: 600; }
.vanhan-badges { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; }
.vh-tag { background: #e0e7ff; color: #3730a3; font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 3px; }

/* CỘT PHẢI: KẾT QUẢ & QUẺ DỊCH */
.eval-card { padding: 12px; border-radius: 8px; border: 1.5px solid #cbd5e1; }
.eval-neutral { background: #f8fafc; }
.eval-cat { background: #f0fdf4; border-color: #22c55e; }
.eval-binh { background: #fefce8; border-color: #eab308; }
.eval-hung { background: #fef2f2; border-color: #ef4444; }
.eval-top { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 13px; margin-bottom: 4px; }
.badge-status { padding: 2px 8px; border-radius: 12px; font-size: 11px; background: #1e293b; color: #fff; }
.eval-sub { font-size: 11.5px; color: #334155; }

.sec-heading { font-weight: 800; font-size: 12px; color: #1e3a8a; border-bottom: 1.5px solid #bfdbfe; padding-bottom: 4px; margin-bottom: 8px; }
.hex-meta { font-size: 11.5px; color: #475569; font-weight: 600; margin-bottom: 8px; }
.hex-compare-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #f8fafc; padding: 10px; border-radius: 8px; border: 1px solid #e2e8f0; }
.hex-col { flex: 1; text-align: center; }
.hex-name { font-weight: 800; font-size: 11.5px; color: #991b1b; margin-bottom: 6px; }
.hex-arrow { font-size: 18px; font-weight: bold; color: #2563eb; }

.hao-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin: 3px 0; font-size: 10.5px; font-weight: 600; }
.hao-bar-yang { height: 7px; background: #1e293b; flex: 1; border-radius: 2px; }
.hao-bar-yin { height: 7px; flex: 1; display: flex; justify-content: space-between; }
.hao-bar-yin span { width: 44%; height: 100%; background: #1e293b; border-radius: 2px; }
.hao-dong .hao-bar-yang, .hao-dong .hao-bar-yin span { background: #dc2626; }
.luchao-mini { font-size: 11.5px; background: #fffbeb; padding: 6px 8px; border-radius: 5px; border: 1px solid #fde68a; margin-top: 8px; }

/* BIỂU ĐỒ NGŨ HÀNH */
.nh-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; font-size: 11.5px; font-weight: 700; }
.nh-label { width: 42px; }
.nh-track { flex: 1; height: 10px; background: #e2e8f0; border-radius: 5px; overflow: hidden; }
.nh-fill { height: 100%; transition: 0.3s; }
.nh-pct { width: 38px; text-align: right; font-size: 11px; }

.cc-tags { display: flex; flex-wrap: wrap; gap: 5px; font-size: 11.5px; }
.cc-pill { padding: 3px 8px; border-radius: 12px; font-weight: 700; font-size: 11px; }
.cc-dat { background: #dcfce7; color: #166534; border: 1px solid #86efac; }

/* KHỐI NÚT XUẤT & CHUYỂN ĐỔI TÓM TẮT */
.export-controls { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid #e2e8f0; padding-top: 10px; }
.mode-switch-bar { display: flex; justify-content: space-between; align-items: center; background: #f1f5f9; padding: 6px 10px; border-radius: 6px; }
.switch-label { display: flex; align-items: center; gap: 6px; font-weight: 700; cursor: pointer; font-size: 12px; }
.mode-pill { font-size: 11px; font-weight: 700; color: #0369a1; background: #e0f2fe; padding: 2px 8px; border-radius: 10px; }

/* MODAL QUẢN TRỊ & LỊCH SỬ */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.65); display: flex; align-items: center; justify-content: center; z-index: 5000; padding: 16px; }
.modal-card { background: #fff; border-radius: 12px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 25px 50px rgba(0,0,0,0.35); }
.modal-lg { max-width: 820px; }
.modal-xl { max-width: 1100px; }
.modal-header { background: #1e293b; color: #fff; padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; }
.modal-header-actions { display: flex; gap: 8px; align-items: center; }
.btn-close { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; }
.modal-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }

.admin-tabs { display: flex; gap: 6px; border-bottom: 2px solid #e2e8f0; padding-bottom: 8px; flex-wrap: wrap; }
.admin-tab { padding: 7px 12px; border: 1px solid #cbd5e1; background: #f8fafc; border-radius: 6px; font-weight: 700; cursor: pointer; font-size: 12px; }
.admin-tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.admin-form { background: #f8fafc; padding: 12px; border-radius: 8px; border: 1px solid #e2e8f0; display: flex; flex-direction: column; gap: 8px; }
.admin-form input, .admin-form select, .admin-form textarea { width: 100%; padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 5px; font-size: 12.5px; }
.search-bar { width: 100%; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 6px; }

.table-scroll { max-height: 300px; overflow: auto; border: 1px solid #e2e8f0; border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 7px 9px; border-bottom: 1px solid #e2e8f0; text-align: left; }
th { background: #f1f5f9; font-weight: 700; position: sticky; top: 0; }

/* BẢNG THÔNG BÁO LỚN GIỮA MÀN HÌNH */
.big-alert-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.72); display: flex; align-items: center; justify-content: center; z-index: 8000; padding: 16px; }
.big-alert-card { background: #ffffff; width: 480px; max-width: 95vw; border-radius: 14px; overflow: hidden; box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45); border: 2px solid #cbd5e1; animation: popIn 0.18s ease-out; color: #0f172a; }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.big-alert-header { padding: 14px 20px; font-size: 16px; font-weight: 800; color: #fff; background: #16a34a; display: flex; align-items: center; gap: 10px; }
.big-alert-card.alert-warn .big-alert-header { background: #d97706; }
.big-alert-card.alert-error .big-alert-header { background: #dc2626; }
.big-alert-body { padding: 22px 24px; font-size: 14.5px; font-weight: 600; color: #1e293b; line-height: 1.55; white-space: pre-line; }
.big-alert-footer { padding: 12px 24px 18px; text-align: right; background: #f8fafc; border-top: 1px solid #e2e8f0; }
.btn-alert-big { padding: 10px 28px; font-size: 14px; border-radius: 8px; }

/* HIỆU ỨNG ĐANG LUẬN GIẢI & CHATBOX TRỢ LÝ */
.thinking-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.75); display: flex; align-items: center; justify-content: center; z-index: 6000; }
.thinking-card { background: #fff; padding: 28px 36px; border-radius: 14px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.4); border-top: 5px solid #eab308; max-width: 90vw; color: #0f172a; }
.orbit-spinner { width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 50%; border: 5px solid #e2e8f0; border-top-color: #2563eb; border-right-color: #16a34a; border-bottom-color: #dc2626; border-left-color: #eab308; animation: spinOrbit 1s linear infinite; }
@keyframes spinOrbit { to { transform: rotate(360deg); } }
.thinking-card h4 { font-size: 15px; margin-bottom: 6px; }
.thinking-card p { color: #475569; font-size: 12.5px; font-weight: 600; }

.chat-fab { position: fixed; bottom: 20px; right: 20px; z-index: 3500; background: #1e293b; color: #fde047; border: 2px solid #eab308; padding: 10px 16px; border-radius: 30px; font-weight: 700; cursor: pointer; box-shadow: 0 8px 20px rgba(0,0,0,0.25); }
.mini-chatbox { position: fixed; bottom: 72px; right: 20px; width: 350px; max-width: 92vw; background: #fff; border-radius: 12px; border: 1px solid #cbd5e1; box-shadow: 0 15px 35px rgba(0,0,0,0.25); z-index: 3500; overflow: hidden; display: flex; flex-direction: column; color: #0f172a; }
.chat-header { background: #1e293b; color: #fde047; padding: 10px 14px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.chat-messages { height: 260px; overflow-y: auto; padding: 10px; background: #f8fafc; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.45; }
.msg-ai { background: #e0f2fe; color: #0c4a6e; align-self: flex-start; max-width: 88%; }
.msg-user { background: #dcfce7; color: #064e3b; align-self: flex-end; max-width: 88%; font-weight: 600; }
.chat-input-row { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #e2e8f0; background: #fff; }
.chat-input-row input { flex: 1; padding: 6px 9px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 12px; }

/* TỐI ƯU HIỂN THỊ TRÊN ĐIỆN THOẠI */
@media (max-width: 768px) {
  .top-bar { flex-direction: column; align-items: flex-start; padding: 10px 12px; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .workspace-grid { padding: 8px; gap: 10px; }
  .grid-6o { grid-template-columns: 1fr; }
  .laso-grid { display: flex; flex-direction: column; background: transparent; padding: 0; gap: 8px; }
  .thien-ban-center { order: -1; margin-bottom: 4px; }
  .cung-cell { border: 1.5px solid #cbd5e1; min-height: auto; }
  .hex-compare-box { flex-direction: column; }
  .hex-arrow { transform: rotate(90deg); margin: 2px 0; }
}
