body { margin:0; min-height:100vh; background:var(--background); font-family:var(--font-sans); color:var(--foreground); }
.page { max-width:1100px; margin:0 auto; padding:20px 20px 60px; }

/* Header */
.page-hdr { display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; flex-wrap:wrap; gap:12px; }
.page-hdr h1 { font-size:20px; font-weight:700; margin:0; }
.page-hdr p { font-size:13px; color:var(--muted-fg); margin:2px 0 0; }

/* Stats Cards */
  .stats-row { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin-bottom:20px; }
.stat-card { background:var(--card); border:1px solid var(--border); border-radius:10px; padding:16px 18px; }
.stat-card .label { font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.04em; color:var(--muted-fg); margin-bottom:6px; }
.stat-card .value { font-size:26px; font-weight:700; line-height:1.1; }
.stat-card .sub { font-size:12px; color:var(--muted-fg); margin-top:4px; }
.stat-card .value.success { color:var(--success); }
.stat-card .value.warn { color:var(--warn); }
.stat-card .value.primary { color:var(--primary); }

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

/* Filter Bar */
.filter-bar { display:flex; gap:10px; align-items:center; flex-wrap:wrap; padding:12px 16px; background:var(--card); border:1px solid var(--border); border-radius:10px; margin-bottom:14px; }
.filter-bar select, .filter-bar input {
  padding:8px 12px; border:1px solid var(--border); border-radius:8px; font:inherit; font-size:13px; background:var(--card); color:var(--foreground); outline:none;
}
.filter-bar select:focus, .filter-bar input:focus { border-color:var(--primary); box-shadow:0 0 0 3px rgba(59,89,152,0.08); }
.filter-bar .search-input { flex:1; min-width:180px; }
  .filter-actions { display:flex; gap:6px; margin-left:auto; flex-wrap:wrap; justify-content:flex-end; }

/* Product Table */
.product-table { width:100%; border-collapse:collapse; background:var(--card); border:1px solid var(--border); border-radius:10px; overflow:hidden; }
.product-table thead th { padding:12px 14px; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:var(--muted-fg); text-align:left; border-bottom:1px solid var(--border); background:var(--muted); }
.product-table tbody td { padding:12px 14px; font-size:13px; border-bottom:1px solid var(--border); vertical-align:middle; }
.product-table tbody tr { transition:background .12s; cursor:pointer; }
.product-table tbody tr:hover { background:var(--accent); }
.product-table tbody tr:last-child td { border-bottom:none; }

/* Product cell */
.product-cell { display:flex; align-items:center; gap:10px; }
.product-cell img { width:44px; height:44px; border-radius:6px; object-fit:cover; flex-shrink:0; background:var(--muted); border:1px solid var(--border); }
.product-cell .info { min-width:0; }
.product-cell .name { font-weight:600; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:250px; }
.product-cell .code { font-size:11px; color:var(--muted-fg); font-family:var(--font-mono); }

/* Status badge */
.status-badge { display:inline-flex; align-items:center; gap:4px; padding:3px 10px; border-radius:20px; font-size:11px; font-weight:600; }
.status-badge.done { background:var(--success-light); color:var(--success); }
.status-badge.pending { background:#fff3cd; color:#856404; }
.status-badge.missing { background:var(--warn-light); color:var(--warn); }
.status-badge.loading { background:var(--info-light); color:var(--info); }

/* Color dots */
.color-dots { display:flex; gap:3px; flex-wrap:wrap; }
.color-dot { width:14px; height:14px; border-radius:50%; border:1px solid var(--border); }

/* Detail Panel */
.detail-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.25); z-index:100; justify-content:center; align-items:flex-start; padding:40px 20px; overflow-y:auto; backdrop-filter:blur(2px); }
.detail-overlay.open { display:flex; }
.detail-panel { background:var(--card); border:1px solid var(--border); border-radius:14px; width:720px; max-width:100%; box-shadow:var(--shadow-lg); }
.detail-header { display:flex; align-items:center; justify-content:space-between; padding:16px 20px; border-bottom:1px solid var(--border); }
.detail-header h2 { font-size:16px; font-weight:700; margin:0; }
.detail-body { padding:20px; max-height:70vh; overflow-y:auto; }

/* Description preview */
.desc-group { margin-bottom:16px; }
.desc-group-title { font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:var(--muted-fg); margin-bottom:8px; padding-bottom:6px; border-bottom:1px solid var(--border); }
.desc-row { display:flex; padding:8px 0; gap:12px; }
.desc-label { width:120px; min-width:120px; font-size:12px; font-weight:600; color:var(--muted-fg); text-transform:uppercase; letter-spacing:.03em; padding-top:2px; }
.desc-value { flex:1; font-size:13.5px; line-height:1.65; }
.desc-tagline { font-style:italic; color:var(--primary); }

/* FAQ */
.faq-item { padding:10px 0; border-bottom:1px solid var(--border); }
.faq-item:last-child { border-bottom:none; }
.faq-q { font-size:13px; font-weight:600; color:var(--primary); margin-bottom:4px; }
.faq-a { font-size:13px; color:var(--secondary-fg); line-height:1.6; padding-left:14px; border-left:2px solid var(--border); }

/* Pagination */
.pagination { display:flex; justify-content:center; gap:6px; margin-top:16px; }
.pagination button { padding:6px 14px; border:1px solid var(--border); border-radius:6px; background:var(--card); font:inherit; font-size:12px; cursor:pointer; color:var(--foreground); }
.pagination button:hover { border-color:var(--primary); color:var(--primary); }
.pagination button.active { background:var(--primary); color:var(--primary-fg); border-color:var(--primary); }
.pagination button:disabled { opacity:.4; cursor:not-allowed; }

/* Loading */
.table-loading { text-align:center; padding:40px; color:var(--muted-fg); }
.spinner-sm { display:inline-block; width:18px; height:18px; border:2px solid var(--border); border-top-color:var(--primary); border-radius:50%; animation:spin .6s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

/* Inline Edit Popup */
.agent-editing { padding: 0 4px; border-radius: 4px; transition: all 0.3s; font-weight: 500;}
#inlineEditPopup {
    display: none; position: absolute; z-index: 10000; background: #fff;
    border: 1px solid #e2e8f0; border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    width: 250px; overflow: hidden; font-family: var(--font-sans);
}
.inline-edit-btn {
    display: block; width: 100%; text-align: left; padding: 10px 14px;
    border: none; background: none; font-size: 13px; color: #475569;
    cursor: pointer; transition: all 0.15s; border-bottom: 1px solid #f1f5f9;
}
.inline-edit-btn:hover { background: #f8fafc; color: #0f172a; padding-left: 18px; }
.inline-edit-btn i { width: 18px; text-align: center; margin-right: 6px; color: #64748b; }
.inline-edit-btn:last-child { border-bottom: none; }
.btn-dark { background:#1e293b; color:#fff; border:1px solid #0f172a; }
.btn-dark:hover { background:#334155; }
.btn-outline-dark { background:transparent; color:#1e293b; border:1px solid #cbd5e1; }
.btn-outline-dark:hover { background:#f1f5f9; border-color:#94a3b8; }


/* Responsive */
@media (max-width:768px) {
  .stats-row { grid-template-columns:repeat(2,1fr); }
  .desc-row { flex-direction:column; gap:2px; }
  .desc-label { width:auto; min-width:auto; }
}

/* ═══ AI CHATBOT WIDGET ═══ */
.chat-fab{position:fixed;bottom:94px;right:24px;width:54px;height:54px;border-radius:50%;background:var(--gold,#C5A467);color:#fff;border:none;cursor:pointer;z-index:200;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 18px rgba(180,148,86,0.4);transition:.25s}
.chat-fab:hover{transform:scale(1.08);box-shadow:0 6px 28px rgba(180,148,86,0.55)}
.chat-fab.open{background:#e74c3c}
.chat-fab svg{width:24px;height:24px;fill:currentColor}
.chat-fab .pulse{position:absolute;inset:0;border-radius:50%;background:var(--gold,#C5A467);opacity:.22;animation:fabPulse 2s infinite;pointer-events:none}
@keyframes fabPulse{0%,100%{transform:scale(1);opacity:.22}50%{transform:scale(1.4);opacity:0}}

.chat-panel{position:fixed;bottom:158px;right:24px;width:400px;height:520px;max-height:calc(100vh - 180px);background:#fff;border:1px solid var(--border,#e5e5e5);border-radius:16px;box-shadow:0 8px 36px rgba(0,0,0,.14);z-index:199;display:none;flex-direction:column;overflow:hidden;transition:.25s}
.chat-panel.show{display:flex}
.chat-panel.expanded{width:min(620px,calc(100vw - 280px));height:min(800px,calc(100vh - 100px))}

.chat-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-bottom:1px solid var(--border,#e5e5e5);background:#fafaf8}
.chat-header-left{display:flex;align-items:center;gap:10px}
.chat-dot{width:8px;height:8px;border-radius:50%;background:#16a34a}
.chat-header-title{font-size:.85rem;font-weight:600;color:#1a1a1a}
.chat-header-sub{font-size:.68rem;color:#888}
.chat-header-btns{display:flex;gap:4px}
.chat-hdr-btn{background:none;border:none;cursor:pointer;padding:4px 8px;border-radius:6px;color:#888;font-size:.78rem;transition:.15s}
.chat-hdr-btn:hover{background:#f0f0ee;color:#333}
.chat-hdr-btn.danger:hover{color:#e74c3c}

.chat-messages{flex:1;min-height:0;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:10px;scroll-behavior:smooth}
.chat-bubble{max-width:85%;padding:10px 14px;border-radius:14px;font-size:.82rem;line-height:1.6;box-shadow:0 1px 3px rgba(0,0,0,.06)}
.chat-bubble.user{align-self:flex-end;background:var(--gold,#C5A467);color:#fff;border-bottom-right-radius:4px}
.chat-bubble.ai{align-self:flex-start;background:#f4f3ef;color:#333;border:1px solid #e8e6df;border-bottom-left-radius:4px}
.chat-bubble.ai p{margin-bottom:.3em}.chat-bubble.ai p:last-child{margin-bottom:0}
.chat-bubble.ai code{background:rgba(0,0,0,.05);padding:1px 4px;border-radius:3px;font-size:.78rem;font-family:monospace}
.chat-bubble.ai pre{background:rgba(0,0,0,.04);padding:8px;border-radius:6px;overflow-x:auto;margin:4px 0}
.chat-bubble.ai pre code{background:none;padding:0}
.chat-bubble.ai ul,.chat-bubble.ai ol{padding-left:1.2em;margin:4px 0}

.chat-typing{align-self:flex-start;background:#f4f3ef;border:1px solid #e8e6df;padding:10px 14px;border-radius:14px;border-bottom-left-radius:4px;font-size:.78rem;color:#888;display:none;align-items:center;gap:6px}
.chat-typing.show{display:flex}
.typing-dots span{display:inline-block;width:5px;height:5px;border-radius:50%;background:#aaa;animation:typingB 1.2s infinite}
.typing-dots span:nth-child(2){animation-delay:.2s}
.typing-dots span:nth-child(3){animation-delay:.4s}
@keyframes typingB{0%,80%,100%{transform:translateY(0)}40%{transform:translateY(-4px)}}

.chat-load-more{text-align:center;margin-bottom:6px}
.chat-load-more button{font-size:.7rem;padding:3px 12px;border-radius:999px;border:1px solid var(--border,#e5e5e5);background:#fff;color:#888;cursor:pointer}
.chat-load-more button:hover{background:#f5f5f5}

.chat-input-bar{display:flex;align-items:center;gap:8px;padding:12px 16px;border-top:1px solid var(--border,#e5e5e5);background:#fff}
.chat-input{flex:1;border:none;outline:none;font-size:.82rem;background:#f4f3ef;padding:9px 14px;border-radius:12px;color:#333;font-family:inherit}
.chat-input:focus{box-shadow:0 0 0 1.5px var(--gold,#C5A467)}
.chat-send-btn{background:var(--gold,#C5A467);color:#fff;border:none;width:36px;height:36px;border-radius:10px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:.15s}
.chat-send-btn:hover{opacity:.9}
.chat-send-btn:disabled{opacity:.4;cursor:not-allowed}
.chat-send-btn svg{width:16px;height:16px;fill:currentColor}

@media(max-width:640px){.chat-panel{width:calc(100vw - 32px);right:16px;bottom:80px}}
