:root{
  --navy:#0b1220; --navy2:#111a2c; --surface:#141d33; --surface2:#1a2540; --surface3:#20304f;
  --border:#232f4d; --text:#eef1f8; --text2:#b7c0d6; --text3:#94a0bd; --text4:#7c88a6;
  --accent:#5b7fff; --accent2:#7c9bff; --accent-bg:rgba(91,127,255,.12); --accent-secondary:#7c9bff;
  --green:#33c481; --green-bg:rgba(51,196,129,.12);
  --red:#ef5a6f; --red-bg:rgba(239,90,111,.12);
  --amber:#f0b23e; --amber-bg:rgba(240,178,62,.12);
  --purple:#a980f5; --purple-bg:rgba(169,128,245,.12);
  --radius:10px; --radius-lg:16px; --shadow-md:0 12px 32px rgba(0,0,0,.3);
  --font-display:'Syne',sans-serif; --font-body:'DM Sans',sans-serif; --font-mono:'DM Mono',monospace;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0;background:var(--navy);color:var(--text);font-family:var(--font-body);height:100%;overflow-x:hidden}
#root{height:100vh;display:flex}
button{font-family:var(--font-body);cursor:pointer}
input,textarea,select{font-family:var(--font-body)}
::-webkit-scrollbar{width:8px;height:8px}
::-webkit-scrollbar-thumb{background:var(--surface3);border-radius:8px}
::-webkit-scrollbar-track{background:transparent}

.app-shell{display:flex;width:100%;height:100%}

.sidebar{width:220px;min-width:220px;background:var(--navy2);border-right:1px solid var(--border);display:flex;flex-direction:column;padding:1rem .75rem}
.sidebar.collapsed{width:64px;min-width:64px}
.brand{font-family:var(--font-display);font-weight:800;font-size:1.3rem;padding:.5rem .5rem 1.25rem;color:var(--accent2)}
.nav-item{display:flex;align-items:center;gap:.65rem;padding:.6rem .65rem;border-radius:var(--radius);color:var(--text3);font-size:.88rem;font-weight:500;margin-bottom:.15rem;cursor:pointer;transition:background .12s,color .12s;text-decoration:none;position:relative}
.nav-item:hover{background:var(--surface2);color:var(--text)}
.nav-item.active{background:var(--accent-bg);color:var(--accent2)}
.nav-item.active::before{content:'';position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--accent-secondary)}
.nav-badge{margin-left:auto;background:var(--red);color:#fff;font-size:.68rem;font-weight:700;padding:.1rem .4rem;border-radius:10px;min-width:18px;text-align:center}
.sidebar-footer{margin-top:auto;padding-top:1rem;border-top:1px solid var(--border)}
.user-chip{display:flex;align-items:center;gap:.6rem;padding:.5rem;border-radius:var(--radius);cursor:pointer}
.user-chip:hover{background:var(--surface2)}
.avatar{width:32px;height:32px;border-radius:50%;background:var(--surface3);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:.8rem;color:var(--accent2);overflow:hidden;flex-shrink:0}
.avatar img{width:100%;height:100%;object-fit:cover}
.user-chip .name{font-size:.82rem;font-weight:600;color:var(--text)}
.user-chip .points{font-size:.72rem;color:var(--text4);font-family:var(--font-mono)}

.main{flex:1;display:flex;flex-direction:column;overflow:hidden;background:var(--navy)}
.topbar{display:flex;align-items:center;justify-content:space-between;padding:.9rem 1.5rem;border-bottom:1px solid var(--border);background:var(--navy2)}
.topbar h1{font-family:var(--font-display);font-size:1.15rem;font-weight:700}
.content{flex:1;overflow:auto;padding:1.5rem;min-height:0}

.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:1.25rem}
.btn{background:var(--accent);color:#fff;border:none;border-radius:var(--radius);padding:0 1rem;height:38px;font-weight:600;font-size:.85rem;display:inline-flex;align-items:center;justify-content:center;gap:.4rem;line-height:1;white-space:nowrap;box-sizing:border-box}
.btn:hover{opacity:.92}
.btn.secondary{background:var(--surface2);border:1px solid var(--border);color:var(--text2)}
.btn.danger{background:var(--red-bg);color:var(--red);border:1px solid rgba(239,90,111,.4)}
.btn:disabled{opacity:.5;cursor:not-allowed}
.btn-sm{height:30px;padding:0 .7rem;font-size:.78rem;border-radius:8px}

.input,.textarea,.select{width:100%;background:var(--surface2);border:1px solid var(--border);border-radius:var(--radius);padding:.55rem .75rem;color:var(--text);font-size:.85rem;outline:none}
.input:focus,.textarea:focus,.select:focus{border-color:var(--accent)}
.textarea{resize:vertical;min-height:80px;font-family:var(--font-body)}
label.field-label{display:block;font-size:.76rem;color:var(--text3);margin-bottom:.3rem;font-weight:500}

.badge{display:inline-flex;align-items:center;gap:.3rem;padding:.2rem .55rem;border-radius:20px;font-size:.72rem;font-weight:600}
.badge.open{background:var(--accent-bg);color:var(--accent2)}
.badge.pending{background:var(--amber-bg);color:var(--amber)}
.badge.closed{background:var(--green-bg);color:var(--green)}
.badge.urgent{background:var(--red-bg);color:var(--red)}
.badge.normal{background:var(--surface3);color:var(--text3)}
.badge.high{background:var(--amber-bg);color:var(--amber)}
.badge.low{background:var(--surface3);color:var(--text4)}
.badge.in_progress{background:var(--purple-bg);color:var(--purple)}
.badge.waiting_customer{background:var(--amber-bg);color:var(--amber)}
.badge.archived{background:var(--surface3);color:var(--text4)}

.data-table-wrap{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
table.data-table{width:100%;border-collapse:collapse;font-size:.85rem}
table.data-table th{text-align:left;padding:.6rem .75rem;color:var(--text4);font-weight:600;font-size:.72rem;text-transform:uppercase;letter-spacing:.03em;border-bottom:1px solid var(--border)}
table.data-table td{padding:.65rem .75rem;border-bottom:1px solid var(--border);color:var(--text2)}
table.data-table tr:hover td{background:var(--surface2)}
table.data-table tr{cursor:pointer}

.modal-overlay{position:fixed;inset:0;background:rgba(5,9,20,.7);display:flex;align-items:center;justify-content:center;z-index:100;padding:1rem}
.modal{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);width:100%;max-width:560px;max-height:88vh;overflow:auto;box-shadow:var(--shadow-md)}
.modal-header{display:flex;align-items:center;justify-content:space-between;padding:1.1rem 1.4rem;border-bottom:1px solid var(--border)}
.modal-header h2{font-family:var(--font-display);font-size:1.05rem}
.modal-body{padding:1.4rem}
.modal-footer{display:flex;justify-content:flex-end;gap:.6rem;padding:1rem 1.4rem;border-top:1px solid var(--border)}
.close-x{background:none;border:none;color:var(--text4);font-size:1.2rem;padding:.2rem;display:inline-flex;align-items:center;justify-content:center;min-width:30px;height:30px;box-sizing:border-box;border-radius:8px}
.close-x:hover{background:var(--surface2)}

.stat-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:1rem;margin-bottom:1.5rem}
.stat-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:1.1rem}
.stat-card .num{font-family:var(--font-display);font-size:1.7rem;font-weight:800}
.stat-card .lbl{font-size:.78rem;color:var(--text4);margin-top:.2rem}
.stat-card.alert{background:rgba(239,90,111,.08);border-color:rgba(239,90,111,.25)}
.stat-card .num.alert{color:var(--red)}

.tabs{display:flex;gap:.25rem;border-bottom:1px solid var(--border);margin-bottom:1.25rem}
.tab{padding:.6rem 1rem;font-size:.85rem;font-weight:600;color:var(--text4);border-bottom:2px solid transparent;cursor:pointer}
.tab.active{color:var(--accent2);border-color:var(--accent)}

.login-wrap{min-height:100vh;width:100%;display:flex;align-items:center;justify-content:center;background:radial-gradient(circle at top,#101b33,var(--navy) 60%)}
.login-card{width:100%;max-width:400px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:2.25rem;box-shadow:var(--shadow-md)}
.login-logo{font-family:var(--font-display);font-weight:800;font-size:1.8rem;margin-bottom:.25rem;color:var(--accent2)}
.login-sub{color:var(--text4);font-size:.85rem;margin-bottom:1.75rem}

.empty-state{text-align:center;padding:3rem 1rem;color:var(--text4)}

/* TICKETS */
.ticket-layout{display:flex;height:100%;gap:1.25rem}
.ticket-list-pane{flex:1;min-width:320px;max-width:420px;overflow:auto}
.ticket-detail-pane{flex:3;overflow:auto}
.ticket-row{padding:.85rem 1rem;border-bottom:1px solid var(--border);cursor:pointer}
.ticket-row:hover{background:var(--surface2)}
.ticket-row.selected{background:var(--accent-bg);border-left:3px solid var(--accent)}
.ticket-row .subject{font-weight:600;font-size:.88rem;margin-bottom:.3rem}
.ticket-row .meta{font-size:.72rem;color:var(--text4);display:flex;gap:.5rem;align-items:center}
.event-item{padding:.9rem 1rem;border-radius:var(--radius);background:var(--surface2);margin-bottom:.75rem}
.event-item.internal{background:var(--amber-bg);border:1px dashed rgba(240,178,62,.4)}
.event-header{display:flex;align-items:center;gap:.5rem;margin-bottom:.4rem;font-size:.78rem;color:var(--text4)}

/* KB */
.kb-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:1rem}
.kb-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:1.1rem;cursor:pointer}
.kb-card:hover{border-color:var(--accent)}
.kb-article-body{line-height:1.7;color:var(--text2)}

/* REWARDS */
.leaderboard-row{display:flex;align-items:center;gap:.75rem;padding:.7rem 0;border-bottom:1px solid var(--border)}
.rank-num{width:28px;text-align:center;font-family:var(--font-display);font-weight:800;color:var(--text4)}
.rank-num.top1{color:#ffd25f}
.rank-num.top2{color:#c8ccd6}
.rank-num.top3{color:#d99a5b}
.spin-wheel-wrap{display:flex;flex-direction:column;align-items:center;padding:2rem}
.catalog-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:1rem}
.catalog-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:1.1rem;text-align:center}

/* DECISION TREES */
.canvas-wrap{position:relative;width:100%;height:100%;overflow:auto;background:
  linear-gradient(var(--surface2) 1px,transparent 1px),
  linear-gradient(90deg,var(--surface2) 1px,transparent 1px);
  background-size:24px 24px;background-color:var(--navy)}
.tree-node{position:absolute;background:var(--surface);border:2px solid var(--border);border-radius:var(--radius);padding:.75rem .9rem;width:180px;cursor:move;box-shadow:var(--shadow-md);user-select:none}
.tree-node.question{border-color:var(--accent)}
.tree-node.outcome{border-color:var(--green)}
.tree-node .node-title{font-weight:700;font-size:.82rem;margin-bottom:.2rem}
.tree-node .node-type-badge{font-size:.62rem;color:var(--text4);text-transform:uppercase;letter-spacing:.03em}

/* KB DOC-TOOL LAYOUT */
.kb-doc-layout{display:flex;gap:1.5rem;height:100%;align-items:flex-start}
.kb-doc-sidebar{width:280px;min-width:280px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:1rem;max-height:calc(100vh - 180px);overflow:auto}
.kb-doc-main{flex:1;min-width:0;max-height:calc(100vh - 180px);overflow:auto}
.tree-article-row.active-article{background:var(--accent-bg);color:var(--accent2)}
.rot-90{transform:rotate(90deg)}
.rot-neg90{transform:rotate(-90deg)}
.kb-tree{font-size:.85rem}
.tree-manual{margin-bottom:.3rem}
.tree-manual-row{display:flex;align-items:center;gap:.5rem;padding:.45rem .5rem;border-radius:var(--radius);cursor:pointer;font-weight:600;color:var(--text)}
.tree-manual-row:hover{background:var(--surface2)}
.tree-count{margin-left:auto;font-size:.68rem;color:var(--text4);font-family:var(--font-mono)}
.tree-children{padding-left:1.1rem;border-left:1px solid var(--border);margin-left:.7rem}
.tree-chapter-row{display:flex;align-items:center;gap:.45rem;padding:.4rem .5rem;border-radius:var(--radius);cursor:pointer;font-weight:500;color:var(--text2);font-size:.82rem}
.tree-chapter-row:hover{background:var(--surface2)}
.tree-article-row{display:flex;align-items:center;gap:.5rem;padding:.35rem .5rem .35rem 1.6rem;border-radius:var(--radius);cursor:pointer;color:var(--text3);font-size:.8rem}
.tree-article-row:hover{background:var(--surface2);color:var(--accent2)}
.tree-add-row{display:flex;align-items:center;gap:.4rem;padding:.35rem .5rem;border-radius:var(--radius);cursor:pointer;color:var(--text4);font-size:.78rem}
.tree-add-row:hover{background:var(--surface2);color:var(--accent2)}
.tree-empty{padding:.3rem .5rem .3rem 1.6rem;color:var(--text4);font-size:.76rem;font-style:italic}

/* QUILL RICH TEXT EDITOR - dark theme overrides */
.ql-toolbar.ql-snow{background:var(--surface2);border:1px solid var(--border) !important;border-bottom:none !important;border-radius:var(--radius) var(--radius) 0 0}
.ql-container.ql-snow{border:1px solid var(--border) !important;border-radius:0 0 var(--radius) var(--radius);font-family:var(--font-body);font-size:.9rem;background:var(--surface2)}
.ql-editor{color:var(--text);min-height:200px}
.ql-editor.ql-blank::before{color:var(--text4);font-style:normal}
.ql-snow .ql-stroke{stroke:var(--text3)}
.ql-snow .ql-fill,.ql-snow .ql-stroke.ql-fill{fill:var(--text3)}
.ql-snow .ql-picker{color:var(--text3)}
.ql-snow .ql-picker-options{background:var(--surface);border:1px solid var(--border) !important}
.ql-snow .ql-picker-label{border:none !important}
.ql-snow .ql-tooltip{background:var(--surface);border:1px solid var(--border);color:var(--text);box-shadow:var(--shadow-md)}
.ql-snow .ql-tooltip input[type=text]{background:var(--surface2);border:1px solid var(--border);color:var(--text)}
.ql-toolbar.ql-snow button:hover .ql-stroke,.ql-toolbar.ql-snow button.ql-active .ql-stroke{stroke:var(--accent2)}
.ql-toolbar.ql-snow button:hover .ql-fill,.ql-toolbar.ql-snow button.ql-active .ql-fill{fill:var(--accent2)}
.ql-toolbar.ql-snow .ql-picker-label:hover,.ql-toolbar.ql-snow .ql-picker-label.ql-active{color:var(--accent2)}
.kb-article-body img,.ql-editor img{max-width:100%;border-radius:8px;margin:.5rem 0}
.kb-video-embed,.ql-video{display:block;width:100%;max-width:100%;aspect-ratio:16/9;border-radius:8px;margin:.75rem 0;background:#000;border:none}
.kb-article-body h1,.kb-article-body h2,.kb-article-body h3{font-family:var(--font-display);color:var(--text);margin:1rem 0 .5rem}
.kb-article-body a{color:var(--accent2)}
.kb-article-body blockquote{border-left:3px solid var(--accent);padding-left:1rem;color:var(--text3);margin:.75rem 0}
.kb-article-body pre{background:var(--navy2);padding:.75rem 1rem;border-radius:var(--radius);overflow:auto}

/* TASKS KANBAN */
.kanban-board{display:flex;gap:1rem;height:100%;overflow-x:auto;align-items:flex-start;min-height:0}
.kanban-column{flex:1;min-width:270px;max-width:340px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);display:flex;flex-direction:column;max-height:100%;min-height:0}
.kanban-column.drag-over{border-color:var(--accent);background:var(--accent-bg)}
.kanban-column-header{display:flex;align-items:center;justify-content:space-between;padding:.9rem 1rem;border-bottom:1px solid var(--border)}
.kanban-column-title{font-weight:700;font-size:.85rem}
.kanban-column-count{font-family:var(--font-mono);font-size:.72rem;color:var(--text4);background:var(--surface2);padding:.1rem .5rem;border-radius:10px}
.kanban-cards{flex:1;overflow-y:auto;padding:.75rem;display:flex;flex-direction:column;gap:.6rem;min-height:0}
.task-card{background:var(--surface2);border:1px solid var(--border);border-radius:var(--radius);padding:.75rem .85rem;cursor:grab;transition:border-color .12s}
.task-card:hover{border-color:var(--accent)}
.task-card:active{cursor:grabbing}
.task-card-title{font-size:.85rem;font-weight:600;margin-bottom:.5rem;line-height:1.4}
.task-card-meta{display:flex;align-items:center;justify-content:space-between;gap:.4rem}
.task-card-ticket{font-size:.7rem;color:var(--accent2);background:var(--accent-bg);padding:.1rem .4rem;border-radius:6px;display:inline-block;margin-bottom:.4rem}

/* NOTIFICATIONS */
.notif-bell{position:relative;cursor:pointer;padding:.5rem;border-radius:50%;color:var(--text3);display:flex}
.notif-bell:hover{background:var(--surface2);color:var(--text)}
.notif-badge{position:absolute;top:2px;right:2px;background:var(--red);color:#fff;font-size:.6rem;font-weight:700;min-width:15px;height:15px;border-radius:8px;display:flex;align-items:center;justify-content:center;padding:0 .3rem;line-height:1}
.notif-dropdown{position:absolute;top:calc(100% + .6rem);right:0;width:340px;max-height:440px;overflow:auto;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);z-index:300}
.notif-header{display:flex;justify-content:space-between;align-items:center;padding:.8rem 1rem;border-bottom:1px solid var(--border);font-weight:700;font-size:.85rem}
.notif-item{padding:.7rem 1rem;border-bottom:1px solid var(--border);cursor:pointer;font-size:.82rem}
.notif-item:hover{background:var(--surface2)}
.notif-item.unread{background:var(--accent-bg)}
.notif-item .notif-title{font-weight:600;color:var(--text);margin-bottom:.15rem}
.notif-item .notif-body{color:var(--text3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.notif-item .notif-time{color:var(--text4);font-size:.7rem;margin-top:.25rem}

/* MENTIONS */
.mention-dropdown{position:absolute;bottom:100%;left:0;margin-bottom:.3rem;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-md);max-height:180px;overflow:auto;z-index:50;min-width:200px}
.mention-item{padding:.5rem .7rem;cursor:pointer;font-size:.85rem;display:flex;align-items:center;gap:.5rem}
.mention-item:hover,.mention-item.active{background:var(--surface2)}
.mention-tag{color:var(--accent2);font-weight:600}

/* KANBAN DRAG POLISH */
.task-card.dragging{opacity:.35;transform:scale(.98)}
.kanban-cards.drop-target{background:var(--accent-bg);border-radius:var(--radius)}
.task-card-drop-indicator{height:3px;background:var(--accent);border-radius:2px;margin:-.3rem 0}

/* CONTACTS */
.contact-row{padding:.85rem 1rem;border-bottom:1px solid var(--border);cursor:pointer;display:flex;align-items:center;gap:.7rem}
.contact-row:hover{background:var(--surface2)}
.contact-row.selected{background:var(--accent-bg);border-left:3px solid var(--accent)}
.contact-photo{width:40px;height:40px;border-radius:50%;background:var(--surface3);display:flex;align-items:center;justify-content:center;font-weight:700;color:var(--accent2);overflow:hidden;flex-shrink:0}
.contact-photo img{width:100%;height:100%;object-fit:cover}
.import-preview-table{width:100%;border-collapse:collapse;font-size:.82rem;margin-top:.75rem}
.import-preview-table th{text-align:left;padding:.4rem .6rem;color:var(--text4);font-size:.7rem;text-transform:uppercase;border-bottom:1px solid var(--border)}
.import-preview-table td{padding:.4rem .6rem;border-bottom:1px solid var(--border);color:var(--text2)}
.import-tag{font-size:.68rem;font-weight:700;padding:.1rem .45rem;border-radius:10px}
.import-tag.new{background:var(--green-bg);color:var(--green)}
.import-tag.update{background:var(--accent-bg);color:var(--accent2)}
.import-tag.skipped{background:var(--red-bg);color:var(--red)}

/* BOOKMARKS */
.bookmark-card{cursor:pointer;transition:transform .12s,border-color .12s}
.bookmark-card:hover{border-color:var(--accent);transform:translateY(-2px)}
.bookmark-card-url{font-size:.7rem;color:var(--text4);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:.2rem}

/* CHAT ATTACHMENTS */
.chat-attach-btn{background:var(--surface2);border:1px solid var(--border);border-radius:var(--radius);width:42px;height:42px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--text3);flex-shrink:0}
.chat-attach-btn:hover{color:var(--accent2);border-color:var(--accent)}
.chat-attachment-image{max-width:260px;max-height:220px;border-radius:var(--radius);cursor:pointer;display:block;margin-top:.4rem}
.chat-attachment-file{display:flex;align-items:center;gap:.6rem;background:var(--surface3);border-radius:var(--radius);padding:.6rem .8rem;margin-top:.4rem;max-width:280px;text-decoration:none;color:var(--text2)}
.chat-attachment-file:hover{border:1px solid var(--accent)}

/* WIDGETS */
.widget-frame-wrap{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);overflow:hidden;height:calc(100vh - 220px);display:flex;flex-direction:column}
.widget-frame-header{display:flex;align-items:center;justify-content:space-between;padding:.8rem 1.1rem;border-bottom:1px solid var(--border);gap:.8rem}
.widget-frame-note{background:var(--amber-bg);color:var(--amber);font-size:.75rem;padding:.5rem 1.1rem;border-bottom:1px solid var(--border)}
.widget-iframe{flex:1;width:100%;border:none;background:#fff}

/* PEOPLE */
.employee-card{cursor:pointer;text-align:center;padding:1.25rem 1rem}
.employee-card:hover{border-color:var(--accent)}
.total-banner{display:flex;gap:1.5rem;padding:1.25rem;background:linear-gradient(135deg,var(--surface2),var(--surface3));border-radius:var(--radius-lg);margin-bottom:1.25rem}
.total-banner .total-item .num{font-family:var(--font-display);font-weight:800;font-size:1.6rem;color:var(--accent2)}
.total-banner .total-item .lbl{font-size:.75rem;color:var(--text4);margin-top:.2rem}

/* TIME CLOCK */
.clock-widget{position:relative;display:flex;align-items:center;gap:.4rem;padding:.4rem .7rem;border-radius:20px;cursor:pointer;font-size:.78rem;font-weight:600;border:1px solid var(--border)}
.clock-widget.status-out{color:var(--text4);background:var(--surface2)}
.clock-widget.status-work{color:var(--green);background:var(--green-bg);border-color:rgba(51,196,129,.3)}
.clock-widget.status-break{color:var(--amber);background:var(--amber-bg);border-color:rgba(240,178,62,.3)}
.clock-dropdown{position:absolute;top:calc(100% + .6rem);right:0;width:240px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);z-index:300;padding:1rem}

/* SCROLLABLE SELECT */
.scroll-select-trigger{display:flex;align-items:center;justify-content:space-between;gap:.5rem;cursor:pointer}
.scroll-select-list{position:absolute;top:calc(100% + .3rem);left:0;right:0;max-height:220px;overflow-y:auto;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-md);z-index:120}
.scroll-select-option{padding:.55rem .8rem;font-size:.85rem;cursor:pointer;color:var(--text2)}
.scroll-select-option:hover{background:var(--surface2)}
.scroll-select-option.selected{background:var(--accent-bg);color:var(--accent2);font-weight:600}

/* AUDIO CALLING */
.incoming-call-overlay{position:fixed;inset:0;background:rgba(6,10,20,.75);display:flex;align-items:center;justify-content:center;z-index:900}
.incoming-call-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);padding:2rem;text-align:center;width:320px}
.incoming-call-pulse{width:80px;height:80px;border-radius:50%;margin:0 auto 1rem;display:flex;align-items:center;justify-content:center;background:var(--accent-bg);animation:callpulse 1.4s infinite}
@keyframes callpulse{0%{box-shadow:0 0 0 0 var(--accent-bg)}70%{box-shadow:0 0 0 18px rgba(0,0,0,0)}100%{box-shadow:0 0 0 0 rgba(0,0,0,0)}}
.active-call-bar{position:fixed;bottom:1.5rem;right:1.5rem;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);padding:.9rem 1.2rem;display:flex;align-items:center;gap:1rem;z-index:850;user-select:none}
.active-call-controls{display:flex;gap:.5rem}
.call-icon-btn{width:38px;height:38px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;border:none;background:var(--surface2);color:var(--text2)}
.call-icon-btn.mute{background:var(--surface2);color:var(--text2)}
.call-icon-btn.mute.active{background:var(--amber-bg);color:var(--amber)}
.call-icon-btn.active{background:var(--accent-bg);color:var(--accent2)}
.call-icon-btn.hangup{background:var(--red);color:#fff}
.guide-pointer{position:fixed;z-index:950;pointer-events:none;transform:translate(-2px,-2px);display:flex;flex-direction:column;align-items:flex-start;color:var(--accent2);transition:left .05s linear,top .05s linear}
.guide-pointer-label{background:var(--accent2);color:#fff;font-size:.7rem;font-weight:600;padding:.15rem .45rem;border-radius:4px;margin-left:14px;margin-top:-4px;white-space:nowrap}
.nav-follow-banner{position:fixed;top:1rem;left:50%;transform:translateX(-50%);z-index:860;background:var(--surface);border:1px solid var(--accent);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);padding:.6rem 1rem;display:flex;align-items:center;gap:.6rem;font-size:.82rem;color:var(--text2)}

/* TEAM CHAT */


.chat-layout{display:flex;height:100%}
.chat-channel-list{width:240px;min-width:240px;border-right:1px solid var(--border);overflow:auto}
.chat-channel-item{display:flex;align-items:center;gap:.6rem;padding:.65rem .9rem;cursor:pointer;font-size:.85rem}
.chat-channel-item:hover{background:var(--surface2)}
.chat-channel-item.active{background:var(--accent-bg);color:var(--accent2)}
.chat-main{flex:1;display:flex;flex-direction:column}
.chat-messages{flex:1;overflow:auto;padding:1rem 1.5rem}
.chat-msg{display:flex;gap:.65rem;margin-bottom:1rem}
.chat-msg .bubble-content{background:var(--surface2);border-radius:var(--radius);padding:.55rem .8rem;font-size:.85rem;max-width:480px}
.chat-input-bar{display:flex;gap:.6rem;padding:1rem 1.5rem;border-top:1px solid var(--border)}

.toast{position:fixed;bottom:1.5rem;right:1.5rem;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:.8rem 1.1rem;font-size:.85rem;box-shadow:var(--shadow-md);z-index:200}
.toast.error{border-color:rgba(239,90,111,.4);color:var(--red)}
.toast.success{border-color:rgba(51,196,129,.4);color:var(--green)}

.spinner{width:20px;height:20px;border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
@keyframes pulseRec{0%,100%{opacity:1}50%{opacity:.3}}

/* ===== MOBILE OPTIMIZATION ===== */
.hamburger-btn{display:none;background:none;border:none;color:var(--text);padding:.3rem;cursor:pointer;align-items:center;justify-content:center;flex-shrink:0}
.sidebar-mobile-close{display:none}
.sidebar-backdrop{display:none}

@media (max-width: 860px){
  .app-shell{position:relative;overflow-x:hidden}
  .hamburger-btn{display:flex}
  .sidebar-mobile-close{display:inline-flex}

  .sidebar{
    position:fixed; top:0; left:0; bottom:0; z-index:300;
    width:82vw; max-width:300px; min-width:0;
    transform:translateX(-100%);
    transition:transform .22s ease;
    box-shadow:var(--shadow-md);
  }
  .sidebar.mobile-open{transform:translateX(0)}
  .sidebar-backdrop{
    display:block; position:fixed; inset:0; background:rgba(5,9,20,.6); z-index:290;
    animation:fadeIn .15s ease;
  }
  @keyframes fadeIn{from{opacity:0}to{opacity:1}}

  .main{width:100%; min-width:0}
  .topbar{padding:.75rem 1rem; gap:.6rem}
  .topbar h1{font-size:1.02rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0}
  .content{padding:1rem; overflow-x:hidden}

  /* Split list+detail and tree+doc layouts stack vertically instead of forcing fixed-width side panes */
  .ticket-layout{flex-direction:column; height:auto}
  .ticket-list-pane{max-width:100%; min-width:0; width:100%; max-height:280px}
  .ticket-detail-pane{width:100%}
  .kb-doc-layout{flex-direction:column; height:auto; align-items:stretch}
  .kb-doc-sidebar{width:100%; min-width:0; max-height:220px}
  .kb-doc-main{max-height:none}

  /* Collapse fixed multi-column inline grids to a single column on narrow screens.
     Cards/lists using auto-fill/auto-fit minmax() already self-collapse and are unaffected. */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns: 1fr 2fr"],
  [style*="grid-template-columns: 1fr 1fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr auto auto"],
  [style*="grid-template-columns: 2fr 1fr 2fr auto"],
  [style*="grid-template-columns: 2fr 1fr 1fr auto"],
  [style*="grid-template-columns: 2fr 1.4fr 1fr auto auto auto auto"]{
    grid-template-columns:1fr !important;
  }

  .data-table-wrap{margin:0 -1px}
  table.data-table{font-size:.8rem}

  .modal{max-width:100%; width:100%; max-height:94vh; border-radius:var(--radius-lg) var(--radius-lg) 0 0}
  .modal-overlay{padding:0; align-items:flex-end}

  .stat-grid{grid-template-columns:repeat(2,1fr) !important}

  /* Canvas-based workflow editor is a desktop drag-and-drop power tool; keep it usable rather than
     attempting full touch support, but ensure it never forces the page itself to overflow. */
  .canvas-wrap{min-width:0}
}

@media (max-width: 480px){
  .stat-grid{grid-template-columns:1fr !important}
  .modal-body{padding:1rem !important}
}
