*{box-sizing:border-box;margin:0;padding:0}
:root{--bg:#FAFAF9;--surface:#FFFFFF;--surface2:#F5F4F1;--border:#E8E6E1;--border2:#D4D1CA;--text:#1A1916;--text2:#6B6860;--text3:#A8A59E;--blue:#1D6FEB;--blue-bg:#EEF5FF;--blue-text:#1553B5;--green:#1A7A4A;--green-bg:#EDFAF3;--amber:#96500A;--amber-bg:#FFF6E8;--red:#B83232;--red-bg:#FFF0F0;--radius:10px;--radius-lg:14px}
html,body{height:100%;font-family:'DM Sans',sans-serif;background:var(--bg);color:var(--text);font-size:14px}
.app{display:grid;grid-template-rows:40px 1fr;height:100vh;overflow:hidden}
/* Page Tabs */
.page-tabs{display:flex;align-items:center;gap:0;background:var(--surface);border-bottom:1px solid var(--border);padding:0 16px}
.page-tab{padding:10px 20px;font-size:12px;font-weight:600;cursor:pointer;border:none;background:none;color:var(--text3);border-bottom:2px solid transparent;transition:all .15s;letter-spacing:.02em}
.page-tab:hover{color:var(--text2)}
.page-tab.active{color:var(--blue);border-bottom-color:var(--blue)}
.page-tab .tab-icon{margin-right:5px}
.page-section{display:none;overflow:hidden;height:100%}
.page-section.active{display:flex;flex-direction:column;height:100%}
/* Insights Browser */
.insights-browser{display:flex;height:100%;overflow:hidden}
.ins-list-pane{width:340px;border-right:1px solid var(--border);display:flex;flex-direction:column;background:var(--surface)}
.ins-list-header{padding:14px 16px 12px;border-bottom:1px solid var(--border)}
.ins-list-header h3{font-size:15px;font-weight:600;margin-bottom:6px;letter-spacing:-.2px}
.ins-search{width:100%;padding:8px 12px;border:1px solid var(--border);border-radius:var(--radius);font-size:13px;font-family:inherit;outline:none;background:var(--bg)}
.ins-search:focus{border-color:var(--blue);background:var(--surface)}
.ins-list-stats{display:flex;gap:8px;margin-top:8px}
.ins-stat{font-size:11px;padding:3px 8px;border-radius:6px;font-weight:600}
.ins-stat.total{background:var(--blue-bg);color:var(--blue-text)}
.ins-stat.api{background:var(--green-bg);color:var(--green)}
.ins-items{flex:1;overflow-y:auto;padding:6px}
.ins-item{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:var(--radius);cursor:pointer;transition:all .12s;border:1.5px solid transparent;margin-bottom:4px}
.ins-item:hover{background:var(--surface2)}
.ins-item.active{background:var(--blue-bg);border-color:#93BAF5}
.ins-item-avatar{width:36px;height:36px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;color:#fff;flex-shrink:0}
.ins-item-info{flex:1;min-width:0}
.ins-item-name{font-size:13px;font-weight:600;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ins-item-sub{font-size:11px;color:var(--text3);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ins-item-badge{font-size:10px;padding:2px 7px;border-radius:6px;font-weight:700;flex-shrink:0}
.ins-detail-pane{flex:1;overflow-y:auto;background:var(--bg);padding:20px 24px}
.ins-detail-empty{display:flex;align-items:center;justify-content:center;height:100%;color:var(--text3);font-size:13px;text-align:center}
.ins-detail-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:20px 24px;margin-bottom:14px}
.ins-detail-title{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--text3);margin-bottom:12px}
/* Topbar */
.topbar{display:flex;align-items:center;gap:12px;padding:0 20px;border-bottom:1px solid var(--border);background:var(--surface)}
.logo{font-weight:600;font-size:15px;letter-spacing:-.3px}.logo span{color:var(--blue)}
.url-wrap{flex:1;max-width:420px;display:flex;align-items:center;gap:8px;background:var(--surface2);border:1px solid var(--border);border-radius:var(--radius);padding:0 10px;height:34px}
.url-wrap svg{flex-shrink:0;color:var(--text3)}
.url-input{flex:1;border:none;background:transparent;font-family:inherit;font-size:13px;color:var(--text);outline:none}
.topbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}
.btn{display:inline-flex;align-items:center;gap:6px;font-family:inherit;font-size:13px;font-weight:500;padding:0 14px;height:34px;border-radius:var(--radius);border:1px solid var(--border2);background:var(--surface);color:var(--text);cursor:pointer;transition:all .15s;white-space:nowrap}
.btn:hover{background:var(--surface2)}.btn:active{transform:scale(.98)}.btn:disabled{opacity:.45;cursor:not-allowed;transform:none}
.btn.primary{background:var(--text);color:#fff;border-color:transparent}.btn.primary:hover{background:#2E2D2A}
.btn.danger{background:var(--red-bg);color:var(--red);border-color:#F7C1C1}
/* Body */
.body{display:grid;grid-template-columns:260px 1fr 220px;overflow:hidden}
/* Sidebar */
.sidebar{border-right:1px solid var(--border);overflow-y:auto;display:flex;flex-direction:column}
.sidebar-head{padding:14px 16px 10px;display:flex;align-items:center;justify-content:space-between}
.section-label{font-size:11px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--text3)}
.persona-list{padding:0 10px 10px;display:flex;flex-direction:column;gap:6px}
.persona-card{padding:11px 12px;border-radius:var(--radius);border:1px solid var(--border);background:var(--surface);cursor:pointer;transition:all .15s}
.persona-card:hover{border-color:var(--border2);background:var(--surface2)}
.persona-card.active{border-color:#93BAF5;background:var(--blue-bg)}
.persona-card.running{border-color:#93BAF5;background:var(--blue-bg)}
.p-row{display:flex;align-items:center;gap:8px;margin-bottom:5px}
.avatar{width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:600;flex-shrink:0}
.av1{background:#E8EEF7;color:#2A5DB0}.av2{background:#EAF5F0;color:#1A6B40}.av3{background:#FDF0E8;color:#924A0E}
.p-name{font-size:13px;font-weight:500;flex:1;letter-spacing:-.1px}
.badge{font-size:11px;font-weight:500;padding:2px 8px;border-radius:999px}
.badge.ok{background:var(--green-bg);color:var(--green)}.badge.hmm{background:var(--amber-bg);color:var(--amber)}.badge.fail{background:var(--red-bg);color:var(--red)}.badge.running{background:var(--blue-bg);color:var(--blue-text)}
.p-desc{font-size:12px;color:var(--text2);line-height:1.45;margin-bottom:5px}
.score-track{height:4px;background:var(--surface2);border-radius:2px;overflow:hidden}
.score-fill{height:4px;border-radius:2px;background:var(--blue);transition:width .5s}
.score-label{font-size:11px;color:var(--text3);margin-top:3px;font-family:'DM Mono',monospace}
/* Progress */
.progress-wrap{padding:8px 16px;border-bottom:1px solid var(--border);background:var(--blue-bg);display:none}
.progress-wrap.show{display:block}
.progress-track{height:3px;background:#BDD4F7;border-radius:2px;overflow:hidden}
.progress-fill{height:3px;background:var(--blue);border-radius:2px;transition:width .4s}
.progress-meta{display:flex;justify-content:space-between;margin-top:5px;font-size:11px;color:var(--blue-text)}
/* Chat */
.chat-wrap{display:flex;flex-direction:column;overflow:hidden;background:var(--bg)}
.chat-header{padding:12px 18px;border-bottom:1px solid var(--border);background:var(--surface);display:flex;align-items:center;gap:10px;min-height:50px}
.messages{flex:1;overflow-y:auto;padding:16px 20px;display:flex;flex-direction:column;gap:10px}
.msg-group{display:flex;flex-direction:column;gap:3px}
.msg-meta{font-size:11px;color:var(--text3);font-weight:500;letter-spacing:.02em;padding:0 4px}
.msg-meta.right{text-align:right}
.bubble{padding:9px 13px;border-radius:var(--radius-lg);font-size:13px;line-height:1.55;max-width:75%;word-wrap:break-word}
.bubble.user{background:var(--text);color:#fff;border-radius:var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);align-self:flex-end;margin-left:auto}
.bubble.bot{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;align-self:flex-start}
.bubble.system{background:var(--surface2);border:1px solid var(--border);border-radius:var(--radius);font-size:12px;color:var(--text2);align-self:center;max-width:90%;text-align:center;padding:7px 14px}
.bubble.decision{align-self:center;max-width:90%;text-align:center;padding:8px 14px;font-size:12px;font-weight:500;border-radius:var(--radius)}
.bubble.decision.ok{background:var(--green-bg);color:var(--green);border:1px solid #B3E0C8}
.bubble.decision.hmm{background:var(--amber-bg);color:var(--amber);border:1px solid #F5D89A}
.bubble.decision.fail{background:var(--red-bg);color:var(--red);border:1px solid #F7C1C1}
.typing-bubble{background:var(--surface);border:1px solid var(--border);padding:10px 14px;border-radius:var(--radius-lg);display:inline-flex;gap:4px;align-items:center;align-self:flex-start}
.dot{width:5px;height:5px;border-radius:50%;background:var(--text3);animation:bounce .8s infinite}.dot:nth-child(2){animation-delay:.18s}.dot:nth-child(3){animation-delay:.36s}
@keyframes bounce{0%,60%,100%{transform:translateY(0)}30%{transform:translateY(-4px)}}
.empty-chat{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--text3);gap:10px}
.empty-icon{width:48px;height:48px;background:var(--surface2);border-radius:50%;display:flex;align-items:center;justify-content:center}
/* Metrics */
.metrics-panel{border-left:1px solid var(--border);overflow-y:auto;padding:0;display:flex;flex-direction:column}
.panel-tabs{display:flex;border-bottom:1px solid var(--border);flex-shrink:0}
.panel-tab{flex:1;padding:10px 8px;font-size:11px;font-weight:600;letter-spacing:.04em;text-align:center;cursor:pointer;background:none;border:none;color:var(--text3);border-bottom:2px solid transparent;transition:all .15s}
.panel-tab:hover{color:var(--text2);background:var(--surface2)}
.panel-tab.active{color:var(--blue);border-bottom-color:var(--blue);background:var(--blue-bg)}
.panel-body{flex:1;overflow-y:auto;padding:14px}
.panel-section{display:none}.panel-section.active{display:block}
.metric-card{background:var(--surface2);border-radius:var(--radius);padding:11px 12px;margin-bottom:8px}
.metric-card-label{font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--text3);margin-bottom:4px}
.metric-card-value{font-size:22px;font-weight:600;letter-spacing:-.5px;font-family:'DM Mono',monospace}
.divider{height:1px;background:var(--border);margin:12px 0}
.funnel-row{display:flex;align-items:center;gap:8px;margin-bottom:8px}
.funnel-bar-bg{flex:1;height:6px;background:var(--surface2);border-radius:3px;overflow:hidden}
.funnel-bar-fill{height:6px;border-radius:3px;transition:width .5s}
.funnel-label{font-size:12px;color:var(--text2);width:60px;font-weight:500}
.funnel-pct{font-size:11px;color:var(--text3);min-width:28px;text-align:right;font-family:'DM Mono',monospace}
.insight-box{background:var(--surface2);border-radius:var(--radius);padding:11px 12px;font-size:12px;color:var(--text2);line-height:1.5;margin-top:8px}
/* Insight layers */
.ins-layer{padding:10px 12px;border-radius:var(--radius);margin-bottom:8px;border-left:3px solid var(--border2)}
.ins-layer-hd{display:flex;align-items:center;gap:6px;margin-bottom:4px}
.ins-layer-icon{font-size:14px}
.ins-layer-label{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.06em}
.ins-layer-val{font-size:12px;line-height:1.55;color:var(--text)}
.ins-loading{text-align:center;padding:20px;color:var(--text3);font-size:12px}
.ins-empty{text-align:center;padding:30px 12px;color:var(--text3);font-size:12px}
/* Segment */
.seg-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:20px 24px;margin-bottom:14px}
.seg-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:12px}
.seg-item{padding:10px 14px;border-radius:var(--radius);border:1px solid var(--border)}
.seg-item-label{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--text3);margin-bottom:4px}
.seg-item-value{font-size:13px;font-weight:600}
.seg-tag{display:inline-flex;align-items:center;gap:4px;font-size:11px;font-weight:700;padding:3px 10px;border-radius:999px;margin:2px 3px 2px 0}
.seg-tag.green{background:#ECFDF5;color:#059669}
.seg-tag.blue{background:#EFF6FF;color:#2563EB}
.seg-tag.purple{background:#F5F3FF;color:#7C3AED}
.seg-tag.amber{background:#FFFBEB;color:#D97706}
.seg-tag.red{background:#FEF2F2;color:#DC2626}
.seg-tag.pink{background:#FDF2F8;color:#DB2777}
.seg-tag.teal{background:#F0FDFA;color:#0D9488}
.seg-tag.gray{background:var(--surface2);color:var(--text2)}
.intent-bar{display:flex;align-items:center;gap:8px;margin-top:6px}
.intent-track{flex:1;height:8px;background:var(--surface2);border-radius:4px;overflow:hidden}
.intent-fill{height:8px;border-radius:4px;transition:width .5s ease}
.intent-score{font-size:14px;font-weight:800;font-family:'DM Mono',monospace;min-width:32px;text-align:right}
.seg-summary{background:linear-gradient(135deg,#EEF2FF 0%,#F0FDF4 100%);border:1px solid #C7D2FE;border-radius:var(--radius-lg);padding:16px 20px;margin-bottom:14px}
.seg-summary-title{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:#6366F1;margin-bottom:8px}
.seg-summary-text{font-size:13px;line-height:1.65;color:var(--text)}
/* Modal */
.modal-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:100;align-items:center;justify-content:center}
.modal-overlay.show{display:flex}
.modal{background:var(--surface);border-radius:var(--radius-lg);border:1px solid var(--border);padding:24px;width:420px;max-width:90vw;max-height:85vh;overflow-y:auto}
.modal h3{font-size:15px;font-weight:600;margin-bottom:16px}
.form-group{margin-bottom:13px}
.form-label{font-size:12px;font-weight:500;color:var(--text2);margin-bottom:5px;display:block}
.form-input,.form-textarea{width:100%;font-family:inherit;font-size:13px;padding:8px 11px;border-radius:var(--radius);border:1px solid var(--border2);background:var(--bg);color:var(--text);outline:none;transition:border-color .15s}
.form-input:focus,.form-textarea:focus{border-color:#93BAF5;background:var(--surface)}
.form-textarea{min-height:70px;resize:vertical;line-height:1.5}
.modal-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:18px}
::-webkit-scrollbar{width:5px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:var(--border2);border-radius:3px}