/* Operator workspace: restrained monochrome UI with bounded desktop layouts. */
:root { --operator-content: 1280px; --operator-knowledge: 1120px; --operator-composer: 900px; }
body[data-state="dashboard"] .dashboard { width:min(var(--operator-content),100%); margin-inline:auto; transform:none; }
body[data-state="dashboard"] .live-status i.online { background:#111; box-shadow:0 0 0 4px rgba(0,0,0,.08); }
html[data-theme="dark"] body[data-state="dashboard"] .nav-back { color:#f5f5f5; }
.metric-grid,.dash-grid { gap:14px; }
.metric-card,.panel { background:#151515; background-image:none; box-shadow:0 12px 32px rgba(0,0,0,.13); }
.metric-card { min-width:0; }
.metric-icon { width:46px; height:46px; flex:0 0 46px; border:1px solid rgba(255,255,255,.13); border-radius:12px; background:rgba(255,255,255,.07); font-size:0; }
.metric-icon svg { width:23px; height:23px; fill:none; stroke:currentColor; stroke-width:1.65; stroke-linecap:round; stroke-linejoin:round; }

#knowledgeWorkspace { --kb-bg:#fff; --kb-text:#111; --kb-muted:#727272; --kb-soft:#f6f6f6; --kb-line:#e5e5e5; --kb-line-strong:#cacaca; --kb-shadow:0 14px 40px rgba(0,0,0,.10); color:var(--kb-text); }
html[data-theme="dark"] #knowledgeWorkspace { --kb-bg:#171717; --kb-text:#f5f5f5; --kb-muted:#a2a2a2; --kb-soft:#222; --kb-line:#343434; --kb-line-strong:#545454; --kb-shadow:0 16px 48px rgba(0,0,0,.34); }
.knowledge-shell { width:min(var(--operator-knowledge),100%); margin:0 auto; padding:24px 0 174px; }
.knowledge-shell-head { display:flex; align-items:flex-start; justify-content:space-between; gap:28px; padding:14px 2px 30px; }
.knowledge-shell-head h2 { margin:0 0 8px; color:var(--kb-text); font-size:clamp(34px,4vw,48px); line-height:.98; letter-spacing:-.055em; }
.knowledge-shell-head p { max-width:560px; margin:0; color:var(--kb-muted); font-size:14px; line-height:1.55; }
.knowledge-head-actions { display:flex; align-items:center; gap:13px; }
.knowledge-state { color:var(--kb-muted); font-size:11px; font-weight:500; white-space:nowrap; }
.knowledge-state::before { content:""; display:inline-block; width:6px; height:6px; margin:0 7px 1px 0; border-radius:50%; background:currentColor; }
.knowledge-state.error { color:var(--kb-muted); }
.knowledge-primary,.knowledge-secondary { min-height:42px; padding:0 18px; border:1px solid #111; border-radius:10px; font:600 13px/1 Inter,Arial,sans-serif; }
.knowledge-primary { color:#fff; background:#111; }
.knowledge-secondary { color:var(--kb-text); border-color:var(--kb-line-strong); background:var(--kb-bg); }
.knowledge-primary:disabled,.knowledge-secondary:disabled { opacity:.45; cursor:wait; }
html[data-theme="dark"] .knowledge-primary { color:#111; border-color:#f5f5f5; background:#f5f5f5; }
.knowledge-tabs { display:flex; gap:32px; overflow-x:auto; border-bottom:1px solid var(--kb-line); scrollbar-width:none; }
.knowledge-tabs::-webkit-scrollbar { display:none; }
.knowledge-tabs button { position:relative; flex:0 0 auto; padding:0 2px 15px; color:var(--kb-muted); background:transparent; font-size:13px; font-weight:500; }
.knowledge-tabs button span { margin-left:5px; color:var(--kb-muted); }
.knowledge-tabs button.active { color:var(--kb-text); font-weight:650; }
.knowledge-tabs button.active::after { content:""; position:absolute; inset:auto 0 -1px; height:2px; background:var(--kb-text); }
.knowledge-view { padding:26px 0 0; }
.knowledge-view[hidden] { display:none!important; }
.knowledge-shell.showing-product>.knowledge-shell-head,.knowledge-shell.showing-product>.knowledge-tabs { display:none; }

.catalog-toolbar { display:flex; align-items:center; gap:12px; margin-bottom:30px; }
.knowledge-search { display:flex; align-items:center; gap:10px; width:min(520px,100%); padding:0 13px; border:1px solid var(--kb-line); border-radius:11px; background:var(--kb-bg); }
.knowledge-search svg,.document-search svg { width:17px; height:17px; fill:none; stroke:var(--kb-muted); stroke-width:1.6; }
.knowledge-search input,.catalog-toolbar select { min-height:42px; border:0; outline:0; color:var(--kb-text); background:transparent; font-size:13px; }
.knowledge-search input { width:100%; }
.catalog-toolbar select { padding:0 34px 0 12px; border:1px solid var(--kb-line); border-radius:11px; }
.product-groups { display:grid; gap:36px; }
.product-group>header { display:flex; align-items:center; justify-content:space-between; min-height:38px; margin-bottom:10px; }
.group-toggle { display:flex; align-items:center; gap:10px; padding:8px 0; color:var(--kb-text); background:transparent; font-size:14px; }
.group-toggle span { width:16px; color:var(--kb-muted); transition:transform .2s ease; }
.group-toggle small { color:var(--kb-muted); font-weight:400; }
.group-add { width:34px; height:34px; border-radius:50%; color:var(--kb-text); background:transparent; font-size:20px; }
.group-add:hover { background:var(--kb-soft); }
.product-card-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.product-group.is-collapsed .product-card-grid { display:none; }
.product-group.is-collapsed .group-toggle span { transform:rotate(-90deg); }
.product-card { display:grid; grid-template-columns:68px minmax(0,1fr) auto; align-items:center; gap:15px; width:100%; min-height:112px; padding:14px; border:1px solid var(--kb-line); border-radius:16px; color:var(--kb-text); background:var(--kb-bg); text-align:left; transition:border-color .18s ease,box-shadow .18s ease,transform .18s ease; }
.product-card:hover { border-color:var(--kb-line-strong); box-shadow:0 10px 28px rgba(0,0,0,.06); transform:translateY(-1px); }
.product-card:focus-visible { outline:2px solid var(--kb-text); outline-offset:3px; }
.product-card-image { display:grid; place-items:center; width:68px; height:68px; overflow:hidden; border-radius:13px; background:var(--kb-soft); }
.product-card-image img { width:100%; height:100%; object-fit:cover; filter:grayscale(1); }
.product-card-image i { color:var(--kb-muted); font-size:17px; font-style:normal; font-weight:650; }
.product-card-copy { min-width:0; display:flex; flex-direction:column; gap:5px; }
.product-card-copy b { overflow:hidden; font-size:14px; text-overflow:ellipsis; white-space:nowrap; }
.product-card-copy small { display:-webkit-box; overflow:hidden; color:var(--kb-muted); font-size:12px; line-height:1.4; -webkit-box-orient:vertical; -webkit-line-clamp:2; }
.product-card-copy>span { margin-top:3px; font-size:12px; }
.product-card-meta { align-self:stretch; display:grid; grid-template-columns:auto 10px; align-content:space-between; justify-items:end; gap:4px; min-width:74px; color:var(--kb-muted); }
.product-card-meta small { grid-column:1/-1; font-size:10px; }
.product-card-meta i { color:var(--kb-text); font-size:8px; font-style:normal; }
.product-card-meta b { color:var(--kb-muted); font-size:21px; font-weight:400; }
.new-group-row { width:100%; min-height:58px; margin-top:28px; padding:0 18px; border:1px dashed var(--kb-line-strong); border-radius:13px; color:var(--kb-muted); background:transparent; text-align:left; }
.new-group-row span { margin-right:12px; color:var(--kb-text); font-size:20px; }
.knowledge-empty { min-height:180px; border-color:var(--kb-line-strong); color:var(--kb-muted); background:transparent; }
.knowledge-empty b { color:var(--kb-text); }

.document-library { padding:5px 2px; color:var(--kb-text); background:transparent; }
.document-library-head { border:0; }
.document-library-head h3 { color:var(--kb-text); }
.document-library-head p { color:var(--kb-muted); }
.document-library-head button { color:#fff; background:#111; }
.document-library-toolbar,.document-row,.document-expanded { border-color:var(--kb-line); }
.document-search input,.document-row,.document-heading { color:var(--kb-text); }
.document-description,.document-filename,.document-details,.document-status,.document-status small,.document-chevron,.document-format { color:var(--kb-muted); }
.document-row-actions button { border-color:var(--kb-line); color:var(--kb-text); background:var(--kb-bg); }
.document-row-actions button.is-primary { color:#fff; background:#111; }
.document-uploader { color:var(--kb-text); }
.document-library #documentUploadForm { border-color:var(--kb-line); background:var(--kb-soft); }
.document-uploader input,.document-uploader textarea,.document-uploader select { color:var(--kb-text); border-color:var(--kb-line); background:var(--kb-bg); }
.file-drop { color:var(--kb-text); border-color:var(--kb-line-strong); background:var(--kb-bg); }
.file-drop small,.knowledge-check { color:var(--kb-muted); }
.knowledge-prompt-card { max-width:840px; padding:22px 2px; }
.knowledge-kicker { color:var(--kb-muted); font-size:12px; }
.knowledge-prompt-card h3 { margin:9px 0; color:var(--kb-text); font-size:28px; letter-spacing:-.035em; }
.knowledge-prompt-card>p { max-width:680px; margin:0 0 22px; color:var(--kb-muted); font-size:13px; line-height:1.6; }
.knowledge-prompt-card textarea { width:100%; min-height:250px; padding:16px; border:1px solid var(--kb-line); border-radius:12px; outline:0; color:var(--kb-text); background:var(--kb-bg); font:14px/1.6 Inter,Arial,sans-serif; resize:vertical; }

.product-page { padding-top:8px; }
.product-back { padding:9px 0 20px; color:var(--kb-text); background:transparent; font-size:13px; }
.product-page-head { display:grid; grid-template-columns:116px minmax(0,1fr) auto; align-items:center; gap:24px; padding:8px 0 28px; border-bottom:1px solid var(--kb-line); }
.product-image-editor { position:relative; display:grid; place-items:center; width:116px; height:116px; overflow:hidden; border-radius:18px; color:var(--kb-muted); background:var(--kb-soft); cursor:pointer; }
.product-image-editor img { width:100%; height:100%; object-fit:cover; filter:grayscale(1); }
.product-image-editor>span { font-size:25px; font-weight:600; }
.product-image-editor small { position:absolute; inset:auto 7px 7px; padding:5px 7px; border-radius:7px; color:#fff; background:rgba(0,0,0,.72); font-size:10px; text-align:center; }
.product-image-editor input { position:absolute; inset:0; opacity:0; cursor:pointer; }
.product-title-block { min-width:0; }
.product-title-block h3 { margin:0 0 8px; color:var(--kb-text); font-size:clamp(32px,4vw,46px); letter-spacing:-.055em; overflow-wrap:anywhere; }
.product-title-block p { max-width:560px; margin:0 0 10px; color:var(--kb-muted); font-size:14px; line-height:1.45; }
.product-title-block span { color:var(--kb-muted); font-size:11px; }
.product-page-actions { display:flex; gap:9px; }
.product-page-grid { display:grid; grid-template-columns:minmax(0,1fr) 250px; gap:34px; }
.product-form-main { min-width:0; }
.product-section { padding:28px 0; border-bottom:1px solid var(--kb-line); }
.product-section h4,.product-bot-settings h4 { margin:0 0 16px; color:var(--kb-text); font-size:17px; }
.product-section>p { margin:-8px 0 16px; color:var(--kb-muted); font-size:12px; line-height:1.5; }
.product-fields.compact { display:grid; grid-template-columns:1fr 1fr; gap:15px; }
.product-fields.compact label,.product-bot-settings label { display:grid; gap:7px; color:var(--kb-muted); font-size:11px; font-weight:500; }
.product-fields.compact .wide { grid-column:1/-1; }
.product-fields.compact input,.product-fields.compact textarea,.product-bot-settings select { width:100%; min-height:42px; padding:10px 12px; border:1px solid var(--kb-line); border-radius:9px; outline:0; color:var(--kb-text); background:var(--kb-bg); font:13px/1.45 Inter,Arial,sans-serif; resize:vertical; }
.product-fields.compact input:focus,.product-fields.compact textarea:focus,.product-bot-settings select:focus { border-color:var(--kb-line-strong); box-shadow:0 0 0 3px rgba(0,0,0,.04); }
.product-bot-settings { margin-top:28px; padding:0 0 0 28px; border-left:1px solid var(--kb-line); }
.product-bot-settings p { margin-top:18px; color:var(--kb-muted); font-size:12px; line-height:1.55; }
.document-choices { display:grid; gap:0; }
.document-choices>label { display:grid; grid-template-columns:18px 26px minmax(0,1fr) auto; align-items:center; gap:10px; padding:12px 0; border-bottom:1px solid var(--kb-line); color:var(--kb-text); cursor:pointer; }
.document-choices input { position:static; width:16px; height:16px; opacity:1; accent-color:#111; }
.document-choice-icon { display:grid; place-items:center; padding:0; border:0; color:var(--kb-muted); background:transparent; }
.document-choice-icon svg { width:17px; height:19px; fill:none; stroke:currentColor; stroke-width:1.45; stroke-linecap:round; stroke-linejoin:round; }
.document-choices label>span:nth-of-type(2) { padding:0; border:0; color:var(--kb-text); background:transparent; }
.document-choices label b,.document-choices label small { display:block; }
.document-choices label small,.document-choices label>i { margin-top:3px; color:var(--kb-muted); font-size:10px; font-style:normal; }
.attach-product-document { margin-top:12px; padding:8px 0; color:var(--kb-text); background:transparent; font-size:12px; }

.knowledge-ai-dock { position:fixed; z-index:42; left:50%; bottom:calc(18px + var(--safe-bottom,0px)); width:min(var(--operator-composer),calc(100vw - 48px)); transform:translateX(-50%); pointer-events:none; }
.knowledge-ai-thread { width:min(760px,calc(100% - 40px)); max-height:230px; margin:0 auto 8px; overflow-y:auto; pointer-events:auto; scrollbar-width:thin; }
.knowledge-ai-thread:empty { display:none; }
.knowledge-ai-bubble { width:fit-content; max-width:min(620px,92%); margin:6px 0; padding:10px 13px; border:1px solid var(--kb-line); border-radius:15px; color:var(--kb-text); background:var(--kb-bg); box-shadow:0 8px 22px rgba(0,0,0,.06); font-size:12px; line-height:1.45; white-space:pre-wrap; }
.knowledge-ai-bubble.user { margin-left:auto; color:#fff; border-color:#111; background:#111; }
html[data-theme="dark"] .knowledge-ai-bubble.user { color:#111; border-color:#f5f5f5; background:#f5f5f5; }
.knowledge-ai-surface { padding:9px; border:1px solid var(--kb-line); border-radius:27px; background:color-mix(in srgb,var(--kb-bg) 96%,transparent); box-shadow:var(--kb-shadow); backdrop-filter:blur(20px); pointer-events:auto; transition:border-color .18s ease,transform .18s ease; }
.knowledge-ai-surface.is-dragging { border-color:var(--kb-text); transform:translateY(-2px); }
.knowledge-ai-composer { display:grid; grid-template-columns:38px minmax(0,1fr) 42px; align-items:end; gap:7px; min-height:72px; }
.knowledge-ai-composer label,.knowledge-ai-composer button { display:grid; place-items:center; width:38px; height:38px; border-radius:50%; cursor:pointer; }
.knowledge-ai-composer label { color:var(--kb-text); }
.knowledge-ai-composer label:hover { background:var(--kb-soft); }
.knowledge-ai-composer label svg { width:21px; height:21px; fill:none; stroke:currentColor; stroke-width:1.65; stroke-linecap:round; }
.knowledge-ai-composer input { display:none; }
.knowledge-ai-composer textarea { align-self:stretch; width:100%; min-height:54px; max-height:132px; padding:7px 3px; border:0; outline:0; color:var(--kb-text); background:transparent; font:14px/1.45 Inter,Arial,sans-serif; resize:none; }
.knowledge-ai-composer button { width:42px; height:42px; color:#fff; background:#111; }
.knowledge-ai-composer button svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.knowledge-ai-composer button:disabled { opacity:.4; cursor:wait; }
.knowledge-ai-dock>.knowledge-message { display:block; min-height:15px; margin:5px 18px 0; color:var(--kb-muted); font-size:10px; pointer-events:auto; }
.knowledge-ai-dock .ai-attachment-list { display:flex; flex-wrap:wrap; gap:6px; margin:0 5px 5px; }
.knowledge-ai-dock .ai-attachment { display:flex; align-items:center; gap:7px; max-width:250px; padding:6px 7px 6px 10px; border:1px solid var(--kb-line); border-radius:999px; color:var(--kb-text); background:var(--kb-soft); font-size:10px; }
.knowledge-ai-dock .ai-attachment>span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.knowledge-ai-dock .ai-attachment button { width:20px; height:20px; padding:0; border-radius:50%; color:var(--kb-muted); background:var(--kb-bg); }
.knowledge-ai-mobile-head,.knowledge-ai-fab { display:none; }

@media (max-width:1180px) { .metric-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } .knowledge-shell { width:min(100%,980px); } }
@media (max-width:860px) { .product-card-grid { grid-template-columns:1fr; } .product-page-grid { grid-template-columns:minmax(0,1fr) 220px; gap:24px; } }
@media (max-width:760px) {
  body[data-state="dashboard"] .dashboard { width:100%; }
  .metric-grid { grid-template-columns:1fr 1fr; }
  .knowledge-shell { padding:2px 0 104px; }
  .knowledge-shell-head { align-items:center; padding:8px 0 20px; }
  .knowledge-shell-head h2 { font-size:31px; }
  .knowledge-shell-head p,.knowledge-state { display:none; }
  .knowledge-head-actions { margin-left:auto; }
  .knowledge-primary { min-height:40px; padding:0 14px; }
  .knowledge-tabs { gap:26px; }
  .catalog-toolbar { align-items:stretch; flex-direction:column; margin-bottom:22px; }
  .knowledge-search,.catalog-toolbar select { width:100%; }
  .product-groups { gap:29px; }
  .product-card { min-height:96px; grid-template-columns:58px minmax(0,1fr) auto; gap:12px; padding:11px; border-radius:14px; }
  .product-card-image { width:58px; height:58px; border-radius:11px; }
  .product-card-meta { min-width:32px; }
  .product-card-meta small { display:none; }
  .new-group-row { margin-top:22px; }
  .document-library-head { flex-direction:column; }
  .document-library-head button { width:100%; justify-content:space-between; }
  .document-heading { grid-template-columns:24px minmax(0,1fr) 12px; gap:12px; }
  .document-status { display:none; }
  .product-page-head { grid-template-columns:88px minmax(0,1fr); gap:15px; }
  .product-image-editor { width:88px; height:88px; border-radius:15px; }
  .product-title-block h3 { font-size:29px; }
  .product-page-actions { position:fixed; z-index:41; inset:auto 0 0; padding:10px 16px calc(10px + var(--safe-bottom,0px)); border-top:1px solid var(--kb-line); background:var(--kb-bg); }
  .product-page-actions .knowledge-secondary { display:none; }
  .product-page-actions .knowledge-primary { width:100%; }
  .product-page-grid { grid-template-columns:1fr; gap:0; }
  .product-fields.compact { grid-template-columns:1fr; }
  .product-fields.compact .wide { grid-column:auto; }
  .product-bot-settings { margin:0; padding:28px 0; border-left:0; border-bottom:1px solid var(--kb-line); }
  .document-choices>label { grid-template-columns:17px 22px minmax(0,1fr); }
  .document-choices label>i { display:none; }
  .knowledge-ai-dock { display:none; z-index:92; inset:0; width:auto; height:100dvh; padding:calc(14px + var(--safe-top,0px)) 14px calc(14px + var(--safe-bottom,0px)); transform:none; background:var(--kb-bg); pointer-events:auto; }
  .knowledge-ai-dock.is-open { display:flex; flex-direction:column; }
  .knowledge-ai-mobile-head { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:2px 2px 18px; }
  .knowledge-ai-mobile-head>div { display:grid; gap:4px; }
  .knowledge-ai-mobile-head b { color:var(--kb-text); font-size:19px; }
  .knowledge-ai-mobile-head span { color:var(--kb-muted); font-size:11px; }
  .knowledge-ai-mobile-head button { display:grid; place-items:center; width:38px; height:38px; flex:0 0 38px; border-radius:50%; color:var(--kb-text); background:var(--kb-soft); }
  .knowledge-ai-mobile-head button svg { width:19px; height:19px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; }
  .knowledge-ai-thread,.knowledge-ai-thread:empty { display:block; width:100%; max-height:none; flex:1 1 auto; margin:0; padding:10px 2px 18px; overflow-y:auto; }
  .knowledge-ai-thread:empty::before { content:"Прикрепите прайс, PDF или фото — либо опишите, что нужно создать или изменить."; display:block; max-width:280px; margin:22vh auto 0; color:var(--kb-muted); font-size:13px; line-height:1.55; text-align:center; }
  .knowledge-ai-bubble { max-width:88%; box-shadow:none; }
  .knowledge-ai-surface { flex:0 0 auto; border-radius:25px; box-shadow:0 10px 30px rgba(0,0,0,.12); }
  .knowledge-ai-composer { min-height:92px; }
  .knowledge-ai-dock>.knowledge-message { min-height:16px; }
  .knowledge-ai-fab { position:fixed; z-index:44; right:18px; bottom:calc(76px + var(--safe-bottom,0px)); display:grid; place-items:center; width:58px; height:58px; border-radius:50%; color:#fff; background:#111; box-shadow:0 12px 28px rgba(0,0,0,.22); }
  .knowledge-ai-fab svg { width:28px; height:28px; fill:none; stroke:currentColor; stroke-width:1.35; stroke-linecap:round; stroke-linejoin:round; }
  body.knowledge-ai-open { overflow:hidden; }
}
@media (max-width:480px) { .metric-grid { grid-template-columns:1fr; } .metric-card { min-height:112px; } .knowledge-shell-head h2 { font-size:28px; } .knowledge-tabs { gap:22px; } .product-card-copy small { -webkit-line-clamp:1; } }
@media (prefers-reduced-motion:reduce) { .product-card,.knowledge-ai-surface { transition:none; } }
