/* Chỉ huy AI — theo phong cách control-center. Các lớp dp-* bên dưới là kiểu dùng chung
   (trước nằm ở dieuphoi.css; mục Điều phối AI đã gỡ 15/11/2026). */
.dp-card-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
.dp-card-head h3{margin:0}
.dp-tabs{display:inline-flex;gap:4px;padding:3px;border-radius:11px;background:#eef2f8}
.dp-tabs button{border:0;border-radius:9px;padding:7px 14px;background:transparent;color:#5a6b85;font-size:12px;font-weight:700;cursor:pointer}
.dp-tabs button.active{background:#fff;color:#1d2e49;box-shadow:0 2px 8px rgba(24,45,76,.08)}
.dp-badge{display:inline-block;padding:4px 10px;border-radius:999px;font-size:11px;font-weight:750;white-space:nowrap}
.dp-badge.ok{color:#116e48;background:#e2f6ec}
.dp-badge.warn{color:#8a5c0f;background:#fdf0d8}
.dp-badge.bad{color:#a13b34;background:#fde6e4}
.dp-sub{color:#7c8aa0;font-size:11px;margin:2px 0 0}
.dp-hint{color:#6c7a90;font-size:12px;line-height:1.55;margin:0 0 12px}
.dp-label{display:block;margin:10px 0 6px;color:#40516b;font-size:11px;font-weight:750;letter-spacing:.03em}
.dp-select{width:100%;padding:10px 12px;border:1px solid #dce4ee;border-radius:11px;background:#fff;color:#1b2a40;font-size:12.5px}
.dp-select.slim{width:auto;max-width:320px;padding:8px 10px}
.dp-actions{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin-top:12px}
.dp-actions .ghost-button{text-decoration:none}
.dp-danger{color:#bb4a43}
.dp-toast{position:fixed;left:50%;bottom:26px;transform:translateX(-50%);z-index:60;padding:11px 18px;border-radius:12px;background:#17253c;color:#fff;font-size:12.5px;font-weight:650;box-shadow:0 10px 30px rgba(10,20,40,.28)}
#viewChihuy .control-card h3{margin:0 0 10px;font-size:14px;font-weight:750;color:#2b3b54}
#viewChihuy .control-card{margin-bottom:16px}
#viewChihuy .ghost-button{font-size:12px;padding:8px 11px}
#viewChihuy .ghost-button:after{content:none}
#viewChihuy .row-actions{flex-wrap:wrap;justify-content:flex-end}
#viewChihuy .row-actions .ghost-button{min-height:0;padding:6px 10px;font-size:11.5px}
#viewChihuy .account-table td{vertical-align:top}
.ch-work{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:16px;align-items:start}
.ch-chat{display:flex;flex-direction:column;height:calc(100vh - 170px);min-height:460px;margin-bottom:0!important}
.ch-chat-head{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:10px}
.ch-chat-head .dp-select{flex:1;min-width:180px;max-width:none}
.ch-messages{flex:1;overflow-y:auto;display:flex;flex-direction:column;gap:12px;padding:6px 2px 10px}
.ch-empty{margin:auto;max-width:460px;text-align:center;color:#5d6d86;font-size:13px;line-height:1.6}
.ch-empty strong{display:block;margin-bottom:6px;color:#1d2e49;font-size:15px}
.ch-msg{padding:12px 14px;border-radius:14px;font-size:13px;line-height:1.6;color:#22324b}
.ch-user{align-self:flex-end;max-width:82%;background:#eaf3f1;border:1px solid #d3e7e2}
.ch-ai{background:#fff;border:1px solid #e3e9f2}
.ch-plan{background:#f7f9fd;border:1px dashed #c8d5ea}
.ch-error{background:#fdeceb;color:#9a3a33;border:1px solid #f4cfcb}
.ch-wait{display:flex;align-items:center;gap:10px;background:#f2f6fc;color:#4a5b76}
.ch-label{margin-bottom:4px;color:#6a7a92;font-size:11px;font-weight:750;letter-spacing:.02em}
.ch-text{overflow-wrap:anywhere}
.ch-task{margin-top:8px;border:1px solid #e3e9f2;border-radius:11px;background:#fff}
.ch-task summary{cursor:pointer;padding:9px 11px;font-size:12.5px;list-style-position:inside}
.ch-task-brief{color:#5d6d86}
.ch-task-body{padding:0 12px 12px;border-top:1px solid #eef2f7}
.ch-task-body .ch-label{margin-top:10px}
.ch-composer{display:flex;flex-direction:column;gap:8px;padding-top:10px;border-top:1px solid #edf1f6}
.ch-composer textarea{width:100%;box-sizing:border-box;resize:vertical;min-height:58px;max-height:220px;padding:11px 13px;border:1px solid #dce4ee;border-radius:12px;font:inherit;font-size:13px;color:#1b2a40;outline:none}
.ch-composer textarea:focus{border-color:#89aeee;box-shadow:0 0 0 4px rgba(117,160,234,.12)}
.ch-composer-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px;font-size:12px;color:#5d6d86}
.ch-composer-row .dp-select{max-width:360px}
.ch-spacer{flex:1}
.ch-board{position:sticky;top:12px;max-height:calc(100vh - 170px);overflow-y:auto;margin-bottom:0!important}
.ch-summary{display:grid;grid-template-columns:repeat(5,1fr);gap:6px;margin-bottom:12px}
.ch-sum{display:flex;flex-direction:column;align-items:center;padding:8px 2px;border-radius:10px;background:#f3f6fa;font-size:10px;color:#5d6d86;text-align:center}
.ch-sum strong{font-size:17px;color:#1d2e49}
.ch-team{display:flex;flex-direction:column;gap:10px}
.ch-member{padding:11px 12px;border:1px solid #e6ebf3;border-radius:13px;background:#fbfcfe}
.ch-member.main{border-color:#9fd4c6;background:#f3fbf8}
.ch-m-busy{border-color:#a9c4f2;background:#f3f7ff}
.ch-m-error{border-color:#f0c9c5}
.ch-member-head{display:flex;align-items:center;gap:9px}
.ch-who{flex:1;min-width:0;display:flex;flex-direction:column}
.ch-who strong{font-size:13px;color:#1d2e49;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ch-member-actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
#viewChihuy .ch-member-actions .ghost-button{padding:5px 9px;font-size:11px;min-height:0}
.ch-job{margin:7px 0 0;color:#2a56a8;font-size:12px;font-weight:650;overflow-wrap:anywhere}
.ch-err{margin:7px 0 0;color:#a13b34;font-size:11.5px;overflow-wrap:anywhere}
.ch-dot{flex:none;width:10px;height:10px;border-radius:50%;background:#b8c3d3}
.ch-dot.ch-ok{background:#1fae6d}
.ch-dot.ch-busy{background:#3d7be0;animation:chPulse 1.2s ease-in-out infinite}
.ch-dot.ch-bad{background:#d9534a}
.ch-dot.ch-warn{background:#e0a32e}
.dp-badge.ch-ok,.ch-sum.ch-ok strong{color:#116e48}.dp-badge.ch-ok{background:#e2f6ec}
.dp-badge.ch-busy,.ch-sum.ch-busy strong{color:#2459b8}.dp-badge.ch-busy{background:#e3ecfd}
.dp-badge.ch-bad,.ch-sum.ch-bad strong{color:#a13b34}.dp-badge.ch-bad{background:#fde6e4}
.dp-badge.ch-warn,.ch-sum.ch-warn strong{color:#8a5c0f}.dp-badge.ch-warn{background:#fdf0d8}
.dp-badge.ch-off{color:#6a7686;background:#eef1f5}
.ch-spin{width:14px;height:14px;border:2px solid #c3d3ef;border-top-color:#3d7be0;border-radius:50%;animation:chSpin .8s linear infinite}
.ch-url{max-width:260px;overflow-wrap:anywhere;font-size:12px}
.ch-form{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px}
.ch-form label{display:flex;flex-direction:column;gap:6px;color:#40516b;font-size:11.5px;font-weight:700}
.ch-form input:not([type=checkbox]){padding:10px 12px;border:1px solid #dce4ee;border-radius:11px;background:#fff;color:#1b2a40;font-size:12.5px;outline:none}
.ch-form input:focus{border-color:#89aeee;box-shadow:0 0 0 4px rgba(117,160,234,.12)}
.ch-form .ch-wide{grid-column:1/-1}
.ch-form .ch-check{flex-direction:row;align-items:center;gap:8px}
.ch-form [hidden]{display:none}
@keyframes chSpin{to{transform:rotate(360deg)}}
@keyframes chPulse{50%{opacity:.35}}
@media (max-width:980px){.ch-work{grid-template-columns:1fr}.ch-board{position:static;max-height:none}.ch-chat{height:70vh}}
@media (max-width:640px){.ch-summary{grid-template-columns:repeat(3,1fr)}.ch-user{max-width:94%}.ch-composer-row .dp-select{max-width:100%;width:100%}}
.ch-head-actions{margin:0!important}
.ch-draft{background:#fafbfd;border:1px dashed #d9e0ea;color:#6a7a92}
.ch-media{display:flex;flex-direction:column;gap:6px;padding:0 12px 12px}
.ch-media video,.ch-media img{max-width:100%;max-height:420px;border-radius:10px;background:#0b1220}
.ch-media-link{font-size:12px;font-weight:650}
.ch-retry{display:block;margin-top:8px}
/* Sơ đồ kết nối đội AI: AI chính ở giữa, sợi nối sáng chạy khi đang giao việc */
.ch-graph{margin:4px 0 14px;border:1px solid #e6ebf3;border-radius:14px;background:radial-gradient(circle at 50% 45%,#f7fafd 0%,#eef3fa 70%,#e9eef7 100%);overflow:hidden}
.chg{width:100%;display:block}
.chg-edge{stroke:#d7dfeb;stroke-width:1.2}
.chg-edge.st-busy{stroke:#3d7be0;stroke-width:2.2;stroke-dasharray:5 7;stroke-linecap:round;animation:chgFlow .7s linear infinite;filter:drop-shadow(0 0 3px rgba(61,123,224,.8))}
.chg-edge.st-error{stroke:#ecc1bd}
.chg-edge.st-off{stroke:#e8ecf2;stroke-dasharray:2 4}
@keyframes chgFlow{to{stroke-dashoffset:-12}}
.chg-node{cursor:pointer}
.chg-dot{fill:#b8c3d3;stroke:#fff;stroke-width:1.6}
.chg-node.st-idle .chg-dot{fill:#1fae6d}
.chg-node.st-busy .chg-dot{fill:#3d7be0;filter:drop-shadow(0 0 5px rgba(61,123,224,.85))}
.chg-node.st-error .chg-dot{fill:#d9534a}
.chg-node.st-unknown .chg-dot{fill:#e0a32e}
.chg-node.st-off .chg-dot{fill:#ccd4e0}
.chg-halo{fill:#3d7be0;opacity:0;transform-box:fill-box;transform-origin:center;pointer-events:none}
.chg-node.st-busy .chg-halo{animation:chgPulse 1.5s ease-out infinite}
.chg-main .chg-halo{fill:#2fa58a}
@keyframes chgPulse{0%{opacity:.55;transform:scale(1)}80%,100%{opacity:0;transform:scale(2.6)}}
.chg-main-dot{fill:url(#chgGrad);stroke:#fff;stroke-width:2;filter:drop-shadow(0 6px 14px rgba(23,37,60,.35))}
.chg-main.st-busy .chg-main-dot{filter:drop-shadow(0 0 14px rgba(47,165,138,.95))}
.chg-star{fill:#fff;font-size:16px;font-weight:700;text-anchor:middle;dominant-baseline:central;pointer-events:none}
.chg-label{font-size:9px;font-weight:700;fill:#5d6d86;text-anchor:middle}
.chg-main-label{font-size:10px;fill:#1d2e49}
.ch-note{background:#f7fafc;border:1px solid #e3edf2;color:#44586f}
.ch-form .ch-field{display:flex;flex-direction:column;gap:6px;color:#40516b;font-size:11.5px;font-weight:700}
.ch-form .ch-field input{padding:10px 12px;border:1px solid #dce4ee;border-radius:11px;background:#fff;color:#1b2a40;font-size:12.5px;outline:none}
.ch-model-row{display:flex;gap:8px}.ch-model-row input{flex:1;min-width:0}
#viewChihuy .ch-model-row .ghost-button{flex:none;padding:6px 10px;min-height:0}
.ch-form .dp-hint{margin:0}
/* Nút quay về tin mới nhất: dính ở mép dưới khung tin (sticky trong vùng cuộn, không che ô gõ) */
.ch-jump{position:sticky;bottom:6px;z-index:5;align-self:center;flex:none;padding:8px 14px;border:1px solid #9fcfcf;border-radius:999px;background:#fff;color:#0b6b74;font:inherit;font-size:12px;font-weight:750;box-shadow:0 8px 24px #0f2f3a26;cursor:pointer}
.ch-jump:hover{background:#eef8f6}
/* Khu Kết quả & tệp: mọi ảnh/video/link các AI tạo ra, mới nhất trước, cuộn ngang */
.ch-results{flex:none;display:flex;flex-direction:column;gap:6px;margin-top:8px;padding:9px 11px;border:1px solid #cfe7e3;border-radius:13px;background:linear-gradient(180deg,#f2faf8,#eaf5f2)}
.ch-results-label{color:#0b6b74;font-size:11.5px;font-weight:800;letter-spacing:.02em}
.ch-results-list{display:flex;gap:8px;overflow-x:auto;padding-bottom:2px;-webkit-overflow-scrolling:touch}
.ch-thumb{position:relative;flex:none;width:76px;height:58px;border:1px solid #bcdcd6;border-radius:10px;overflow:hidden;background:#0b1220;display:block}
.ch-thumb img,.ch-thumb video{width:100%;height:100%;object-fit:cover;display:block}
.ch-thumb-play{position:absolute;inset:0;display:grid;place-items:center;color:#fff;font-size:17px;text-shadow:0 1px 6px #000c;pointer-events:none}
.ch-thumb-tag{position:absolute;left:3px;bottom:3px;padding:0 5px;border-radius:7px;background:#0b1220cc;color:#aef0dd;font-size:9px;font-weight:800}
.ch-link-chip{flex:none;display:inline-flex;align-items:center;gap:6px;max-width:240px;padding:8px 11px;border:1px solid #c8dfe9;border-radius:999px;background:#fff;color:#1e5a9e;font-size:12px;font-weight:650;text-decoration:none}
.ch-link-chip span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ch-link-chip:hover{background:#f0f7fd}
.ch-pack{background:#0f766e;border-color:#0f766e;color:#fff}
.ch-pack:hover{background:#0b5f58}
.ch-file-chip{color:#2f4a68}
.ch-media .ch-file-chip{margin:4px 6px 0 0}
/* Bảng "AI này đang làm gì": bấm điểm trên sơ đồ hoặc thẻ AI để mở */
.ch-clickable{cursor:pointer;border-radius:10px}
.ch-clickable:hover strong{color:#0b6b74}
.ch-peek{position:fixed;inset:0;z-index:9000;display:grid;place-items:center;padding:16px;background:#0c202866;backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px)}
.ch-peek[hidden]{display:none}
.ch-peek-card{width:min(680px,100%);max-height:min(82vh,760px);display:flex;flex-direction:column;border:1px solid #cfe1e2;border-radius:18px;background:#fff;box-shadow:0 28px 70px #06181f55;overflow:hidden}
.ch-peek-head{flex:none;display:flex;flex-wrap:wrap;align-items:center;gap:9px;padding:13px 15px;border-bottom:1px solid #e8eef2;background:#f7fbfb}
.ch-peek-head .ch-who{flex:1;min-width:140px}
.ch-peek-actions{display:flex;gap:7px;margin-left:auto}
#viewChihuy .ch-peek-actions .ghost-button{padding:7px 11px;font-size:12px;min-height:0}
.ch-peek-body{overflow-y:auto;padding:12px 15px 16px;display:flex;flex-direction:column;gap:8px;overscroll-behavior:contain}
.ch-peek-body .ch-task{margin-top:0}
@media (max-width:640px){
  .ch-peek{padding:10px;align-items:end}
  .ch-peek-card{max-height:86dvh}
  .ch-thumb{width:66px;height:52px}
}
/* --- Điện thoại: khung app CỐ ĐỊNH — cả trang không cuộn, từng khung tự cuộn bên trong.
   Hai ngăn 💬 Giao việc / 🛰 Đội AI chuyển bằng thanh trên cùng (máy tính vẫn 2 cột như cũ).
   Ô chữ dưới 16px bị iOS tự phóng to cả trang khi chạm -> trang "lắc lư" khi vuốt: nâng lên 16px. */
.ch-pane-tabs{display:none}
.ch-pane-badge{display:inline-grid;place-items:center;min-width:18px;padding:1px 6px;border-radius:9px;background:#3d7be0;color:#fff;font-size:10.5px;font-weight:800}
@media (max-width:850px){
  #viewChihuy .row-actions .ghost-button{min-height:0;padding:6px 10px;font-size:11.5px}  /* dòng bảng thấp hơn trên điện thoại */
  #viewChihuy .ch-composer textarea,#viewChihuy .ch-form input:not([type=checkbox]),#viewChihuy select{font-size:16px}
  #viewChihuy{overflow-x:clip}
  .ch-msg,.ch-task,.ch-text{max-width:100%;box-sizing:border-box;min-width:0}
  @supports selector(:has(*)){
    .control-panel:has(#viewChihuy:not([hidden])){overflow:hidden;display:flex;flex-direction:column;padding:12px 12px 8px}
    /* .control-view có margin:0 auto -> item flex không còn stretch mà nở theo bảng rộng bên trong: ép về đúng bề ngang màn */
    #viewChihuy:not([hidden]){flex:1;min-height:0;display:flex;flex-direction:column;width:100%;max-width:none;margin:0}
    #chWork,#chWork .ch-chat,.ch-messages,.ch-msg,.ch-task-body{min-width:0}
    #viewChihuy .control-header{flex:none;margin-bottom:8px}
    #viewChihuy .control-header h2{font-size:18px}
    #viewChihuy .topbar-kicker{display:none}
    #chWork{flex:1;min-height:0;display:flex;flex-direction:column;align-items:stretch}  /* .ch-work gốc align-items:start (lưới 2 cột) làm ngăn không bám bề ngang */
    #chSetup:not([hidden]){flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding-bottom:8px}
    .ch-pane-tabs{flex:none;display:flex;gap:5px;margin:0 0 9px;padding:4px;border:1px solid #d8e3ea;border-radius:13px;background:#e9eff4}
    .ch-pane-tabs button{flex:1;display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:38px;padding:6px;border:0;border-radius:10px;background:transparent;color:#53697f;font:inherit;font-size:13px;font-weight:750;cursor:pointer}
    .ch-pane-tabs button.active{background:#fff;color:#0b6b74;box-shadow:0 2px 8px #16324614}
    #chWork .ch-chat{flex:1;min-height:0;height:auto;margin:0}
    #chWork .ch-board{display:none}
    #chWork.pane-board .ch-chat{display:none}
    #chWork.pane-board .ch-board{display:flex;flex-direction:column;flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;position:static;max-height:none;margin:0}
    #chWork.pane-board .ch-board>*{flex:none}  /* không cho flex ép dẹp sơ đồ/bảng: dài quá thì cuộn */
    /* Đang gõ lệnh (bàn phím ảo che hơn nửa màn): tạm gọn các phần phụ để ô gõ nằm NGAY TRÊN bàn phím,
       không bị đẩy tụt xuống dưới thanh menu. Nhấc tay khỏi ô gõ là mọi thứ trở lại. */
    body.ch-typing #viewChihuy .control-header,
    body.ch-typing #chWork .ch-pane-tabs,
    body.ch-typing #chWork .ch-chat-head,
    body.ch-typing #chWork .ch-results{display:none}
    body.ch-typing #chWork .ch-chat{padding-top:8px}
  }
}
/* Trình xem ảnh/video trong app (PWA iPhone không có nút Back của trình duyệt) */
.ch-viewer{position:fixed;inset:0;z-index:9600;display:flex;flex-direction:column;background:#0b1220f2;backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px)}
.ch-viewer[hidden]{display:none}
.ch-viewer-bar{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:max(10px,env(safe-area-inset-top)) 12px 10px}
#viewChihuy .ch-viewer-bar .ghost-button{display:inline-flex;align-items:center;min-height:42px;padding:9px 15px;font-size:13.5px;font-weight:750;background:#ffffffeb;border-color:#ffffff50;color:#14303a;text-decoration:none}
.ch-viewer-body{flex:1;min-height:0;display:grid;place-items:center;padding:0 10px max(14px,env(safe-area-inset-bottom))}
.ch-viewer-body img,.ch-viewer-body video{max-width:100%;max-height:100%;border-radius:12px;background:#000}
.ch-media img{cursor:zoom-in}
.ch-media-row{display:flex;align-items:center;gap:12px}
#viewChihuy .ch-media-row .ghost-button{padding:6px 11px;font-size:12px;min-height:0}
.ch-thumb{padding:0;border:1px solid #bcdcd6;cursor:zoom-in;font:inherit}
