/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5; color: #1a1a2e; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; font-size: inherit; border: none; outline: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }
.hidden { display: none !important; }

/* ===== LAYOUT ===== */
.main-layout { display: flex; height: 100vh; overflow: hidden; }
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ===== SIDEBAR ===== */
.sidebar { width: 220px; flex-shrink: 0; background: #1a1a2e; color: #fff;
  display: flex; flex-direction: column; overflow: hidden; transition: transform .25s; z-index: 200; }
.sidebar-logo { display: flex; align-items: center; gap: 8px; padding: 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.1); font-size: 1.05rem; font-weight: 700; }
.logo-icon { font-size: 1.4rem; }
.logo-text { font-weight: 700; }
.sidebar-toggle { margin-left: auto; background: none; color: #aaa; display: none; font-size: 1rem; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 16px;
  cursor: pointer; transition: background .15s; border-radius: 6px; margin: 2px 8px;
  font-size: .9rem; color: rgba(255,255,255,.75); }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: #4f46e5; color: #fff; font-weight: 600; }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.1); }
.user-info { font-size: .82rem; color: rgba(255,255,255,.7); margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: #4f46e5;
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; flex-shrink: 0; }
.btn-logout { width: 100%; padding: 7px; background: rgba(255,255,255,.08); color: #fff;
  border-radius: 6px; font-size: .85rem; transition: background .15s; }
.btn-logout:hover { background: rgba(255,255,255,.15); }

/* ===== TOPBAR ===== */
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 20px; height: 52px;
  background: #fff; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.burger-btn { background: none; color: #666; font-size: 1.2rem; display: none; padding: 4px; }
.page-title { font-size: 1rem; font-weight: 700; color: #111; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.notifications-btn { position: relative; cursor: pointer; font-size: 1.15rem; padding: 4px 6px; }
.content { flex: 1; overflow-y: auto; padding: 20px; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; font-size: .875rem; font-weight: 500;
  transition: all .15s; border: 1px solid transparent; white-space: nowrap; }
.btn-primary   { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-secondary { background: #fff; color: #374151; border-color: #d1d5db; }
.btn-secondary:hover { background: #f9fafb; }
.btn-danger    { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success   { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ===== FORMS ===== */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; font-weight: 600; color: #374151; margin-bottom: 5px; }
.form-control {
  width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px;
  background: #fff; transition: border-color .15s; font-size: .875rem; color: #1a1a2e; }
.form-control:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.field-highlight { border-color: #10b981 !important; box-shadow: 0 0 0 3px rgba(16,185,129,.2) !important; transition: border-color .3s, box-shadow .3s; }
textarea.form-control { resize: vertical; min-height: 80px; }
.field input, .field textarea, .field select { /* alias */
  width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px;
  background: #fff; transition: border-color .15s; font-size: .875rem; color: #1a1a2e; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.field textarea { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.error-msg { color: #ef4444; font-size: .82rem; padding: 6px 10px; background: #fef2f2;
  border: 1px solid #fecaca; border-radius: 6px; margin-top: 6px; }

/* ===== CARDS ===== */
.card { background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.07); }

/* ===== TABLES ===== */
.table { width: 100%; border-collapse: collapse; font-size: .875rem; background: #fff;
  border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.07); }
.table th { background: #f9fafb; font-weight: 600; color: #6b7280; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; text-align: left;
  border-bottom: 1px solid #e5e7eb; }
.table td { padding: 10px 12px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f9fafb; }
.table tr:hover td { background: #f9fafb; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 8px; border-radius: 12px; font-size: .75rem; font-weight: 600;
  background: #e5e7eb; color: #374151; }
.badge-secondary { background: #e5e7eb; color: #6b7280; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-success  { background: #d1fae5; color: #065f46; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-ai { background: #ede9fe; color: #5b21b6; font-size: 10px; padding: 1px 5px; border-radius: 4px; }
.badge-channel { font-size: 11px; padding: 2px 7px; border-radius: 4px; }
.badge-status-new     { background: #dbeafe; color: #1e40af; }
.badge-status-open    { background: #d1fae5; color: #065f46; }
.badge-status-pending { background: #fef3c7; color: #92400e; }
.badge-status-closed  { background: #f3f4f6; color: #6b7280; }
/* notification dot */
#notif-badge { position: absolute; top: -4px; right: -4px; background: #ef4444; color: #fff;
  border-radius: 50%; min-width: 18px; height: 18px; font-size: .7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; }
.unread-badge { min-width: 20px; height: 20px; border-radius: 10px; background: #4f46e5;
  color: #fff; font-size: .72rem; font-weight: 700; display: flex; align-items: center;
  justify-content: center; padding: 0 5px; }

/* ===== LOGIN SCREEN ===== */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); }
.login-box { background: #fff; border-radius: 14px; padding: 40px; width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo { display: flex; align-items: center; gap: 10px; justify-content: center;
  margin-bottom: 28px; font-size: 1.3rem; font-weight: 700; color: #1a1a2e; }
.login-logo .logo-icon { font-size: 2rem; }

/* ===== DIALOGS ===== */
.dialogs-layout { display: grid; grid-template-columns: 300px 1fr 280px;
  height: calc(100vh - 92px); margin: -20px; overflow: hidden; }
.dialogs-sidebar { border-right: 1px solid #e5e7eb; background: #fff;
  display: flex; flex-direction: column; overflow: hidden; }
.dialogs-toolbar { padding: 10px; border-bottom: 1px solid #e5e7eb; display: flex; flex-direction: column; gap: 6px; }
.dialogs-list { flex: 1; overflow-y: auto; }
.dialog-item { padding: 12px 14px; border-bottom: 1px solid #f3f4f6; cursor: pointer;
  transition: background .1s; display: flex; gap: 8px; align-items: flex-start; }
.dialog-item:hover { background: #f9fafb; }
.dialog-item.active { background: #eff6ff; border-left: 3px solid #4f46e5; }
.dlg-channel { flex-shrink: 0; padding-top: 2px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.dlg-status-badge { font-size: .6rem; padding: 1px 5px; white-space: nowrap; }
.dlg-info { flex: 1; min-width: 0; }
.dlg-name { font-size: .875rem; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.dlg-city { font-size: .75rem; color: #9ca3af; margin-top: 1px; }
.dlg-last-msg { font-size: .8rem; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.dlg-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.dlg-time { font-size: .72rem; color: #9ca3af; }

/* ===== CHAT ===== */
.dialog-chat { display: flex; flex-direction: column; overflow: hidden; background: #f8f9fc; }
.chat-header { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; flex-wrap: wrap; gap: 8px; }
.chat-header-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chat-header-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.message { max-width: 72%; display: flex; flex-direction: column; }
.msg-in  { align-self: flex-start; }
.msg-out { align-self: flex-end; }
.msg-bubble { padding: 9px 13px; border-radius: 12px; font-size: .875rem; line-height: 1.5;
  word-break: break-word; }
.msg-in  .msg-bubble { background: #fff; border: 1px solid #e5e7eb; border-bottom-left-radius: 3px; }
.msg-out .msg-bubble { background: #4f46e5; color: #fff; border-bottom-right-radius: 3px; }
.msg-sender { font-size: .72rem; font-weight: 600; margin-bottom: 3px; display: inline-block; padding: 1px 7px; border-radius: 8px; }
.msg-sender-client  { background: #f0fdf4; color: #16a34a; }
.msg-sender-manager { background: #eff6ff; color: #2563eb; }
.msg-sender-ai      { background: #faf5ff; color: #7c3aed; }
.msg-out .msg-sender { display: block; text-align: right; }
.msg-meta { font-size: .72rem; color: #9ca3af; margin-top: 3px; }
.msg-out .msg-meta { text-align: right; }
.msg-date-sep { text-align: center; margin: 8px 0; }
.msg-date-sep span { background: #e5e7eb; color: #6b7280; font-size: .75rem; padding: 3px 12px; border-radius: 10px; }
.dlg-header-sub { font-size: .8rem; color: #6b7280; }
.dlg-title-editable { font-weight: 700; cursor: pointer; border-radius: 4px; padding: 2px 6px; transition: background .15s; }
.dlg-title-editable:hover { background: #f3f4f6; }
.btn-xs { padding: 2px 10px; font-size: .78rem; }
.channel-arrow { font-size: .8rem; color: #9ca3af; margin: 0 2px; }
.msg-channel-badge { display: inline-block; font-size: .68rem; font-weight: 600; padding: 1px 6px; border-radius: 8px; margin-left: 5px; vertical-align: middle; border: 1px solid currentColor; }
.msg-channel-badge--avito    { color: #d97706; background: #fffbeb; border-color: #fde68a; }
.msg-channel-badge--telegram { color: #2563eb; background: #eff6ff; border-color: #bfdbfe; }
.msg-channel-badge--whatsapp { color: #16a34a; background: #f0fdf4; border-color: #bbf7d0; }
.msg-channel-badge--vk       { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.msg-channel-badge--email    { color: #7c3aed; background: #faf5ff; border-color: #ddd6fe; }
.channel-switcher { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.channel-btn { font-size: .75rem; padding: 3px 8px; border: 1px solid #e5e7eb; background: #fff; color: #374151; border-radius: 6px; cursor: pointer; transition: all .15s; }
.channel-btn:hover { border-color: #4f46e5; color: #4f46e5; }
.channel-btn.active { background: #4f46e5; color: #fff; border-color: #4f46e5; }
.chat-input-area { padding: 8px 12px 12px; background: #fff; border-top: 1px solid #e5e7eb;
  flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; }
.chat-input-area > div:last-of-type, .chat-input-area > textarea ~ button { align-self: flex-end; }
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-input-target { display: flex; gap: 4px; }
.chat-target-btn { padding: 3px 12px; font-size: .8rem; border: 1px solid #e5e7eb; background: #f9fafb; color: #6b7280; border-radius: 20px; cursor: pointer; transition: all .15s; }
.chat-target-btn.active[data-target="client"]   { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; font-weight: 600; }
.chat-target-btn.active[id="btn-target-internal"] { background: #fefce8; color: #854d0e; border-color: #fde68a; font-weight: 600; }
.chat-target-internal-wrap { position: relative; }
.internal-recipient-picker { position: absolute; bottom: calc(100% + 4px); left: 0; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.1); min-width: 200px; z-index: 100; padding: 4px 0; }
.irp-item { padding: 8px 14px; font-size: .875rem; cursor: pointer; transition: background .1s; white-space: nowrap; }
.irp-item:hover { background: #f3f4f6; }
.irp-active { background: #eff6ff; color: #2563eb; font-weight: 600; }
.irp-disabled { color: #9ca3af; cursor: default; }
.irp-disabled:hover { background: transparent; }
.irp-status { font-size: .7rem; padding: 1px 6px; border-radius: 8px; margin-left: 4px; font-weight: 600; }
.irp-status--on   { background: #dcfce7; color: #16a34a; }
.irp-status--off  { background: #fee2e2; color: #dc2626; }
.irp-status--away { background: #f3f4f6; color: #9ca3af; }
.chat-send-to { font-size: .8rem; padding: 4px 10px; border-radius: 6px; display: flex; align-items: center; gap: 6px; }
.chat-send-to--client { background: #eff6ff; color: #1e40af; }
.chat-send-to--internal { background: #fefce8; color: #92400e; }
.send-to-channel { color: #6b7280; }
.send-to-note { color: #b45309; font-style: italic; }
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; width: 100%; }
.chat-input-row textarea { flex: 1; min-width: 0; resize: none; padding: 9px 12px; border: 1px solid #d1d5db;
  border-radius: 8px; font-size: .875rem; max-height: 120px; min-height: 40px; }
.chat-target-client-wrap { position: relative; }
.input-internal textarea { border-color: #fde68a; background: #fefce8; }
.input-internal #chat-send { background: #d97706; }
.msg-internal { align-self: center; width: 90%; background: #fefce8; border: 1px dashed #fbbf24; border-radius: 10px; padding: 10px 14px; }
.msg-internal-mine { border-color: #f59e0b; background: #fffbeb; }
.msg-internal-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.msg-internal-badge { font-size: .72rem; font-weight: 700; background: #fde68a; color: #92400e; padding: 2px 8px; border-radius: 8px; }
.msg-internal-route { font-size: .8rem; color: #78350f; font-weight: 600; }
.msg-internal-route .mia { color: #d97706; }
.msg-internal .msg-bubble { background: transparent; border: none; padding: 0; font-size: .875rem; color: #1c1917; }
.msg-internal .msg-meta { font-size: .68rem; color: #a16207; margin-top: 4px; }
.chat-input-area textarea { flex: 1; resize: none; padding: 9px 12px; border: 1px solid #d1d5db;
  border-radius: 8px; font-size: .875rem; max-height: 120px; min-height: 40px; }
.chat-input-area textarea:focus { outline: none; border-color: #4f46e5; }
.chat-attach-btn { display:flex; align-items:center; justify-content:center; width:36px; height:36px;
  font-size:1.1rem; cursor:pointer; border-radius:8px; flex-shrink:0; color:#6b7280;
  border:1px solid #e5e7eb; background:#f9fafb; transition:background .15s; }
.chat-attach-btn:hover { background:#f3f4f6; color:#4f46e5; }
.chat-attach-preview { background:#f9fafb; border:1px solid #e5e7eb; border-radius:8px; padding:8px 10px; position:relative; }
.chat-attach-thumb { position:relative; display:inline-block; }
.chat-attach-remove { position:absolute; top:-6px; right:-6px; background:#fff; border:1px solid #e5e7eb;
  border-radius:50%; width:18px; height:18px; font-size:10px; cursor:pointer; display:flex;
  align-items:center; justify-content:center; color:#6b7280; padding:0; line-height:1; }
.chat-attach-remove:hover { background:#fee2e2; color:#dc2626; border-color:#fca5a5; }

/* ===== CLIENT PANEL (right) ===== */
.dialog-client-panel { background: #fff; border-left: 1px solid #e5e7eb; overflow-y: auto; display: flex; flex-direction: column; }
.client-panel-section { padding: 12px 16px; border-bottom: 1px solid #f3f4f6; }
.client-panel-section.cpanel-grow { flex: 1; display: flex; flex-direction: column; }
.client-panel-section.cpanel-grow .cpanel-fields { flex: 1; display: flex; flex-direction: column; }
.client-panel-section.cpanel-grow .cpanel-field:last-child { flex: 1; display: flex; flex-direction: column; }
.client-panel-section.cpanel-grow .cpanel-field:last-child textarea { flex: 1; resize: none; }
.client-panel-section h4 { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
.cpanel-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.cpanel-field { display: flex; flex-direction: column; gap: 2px; }
.cpanel-field label { font-size: .7rem; color: #9ca3af; text-transform: uppercase; letter-spacing: .03em; }
.cpanel-field--messenger { grid-column: 1 / -1; }
.form-control-sm { font-size: .8rem; padding: 4px 8px; height: 30px; }
textarea.form-control-sm { height: auto; }
  color: #9ca3af; font-weight: 600; margin-bottom: 8px; }
.client-panel-section p { font-size: .875rem; margin-bottom: 4px; }

/* ===== ORDERS KANBAN ===== */
.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kanban-col { width: 260px; flex-shrink: 0; background: #f3f4f6; border-radius: 10px; padding: 10px; }
.kanban-col-header { font-size: .82rem; font-weight: 700; padding: 6px 8px;
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; }
.order-card { background: #fff; border-radius: 8px; padding: 10px 12px; cursor: pointer;
  border-left: 3px solid #4f46e5; box-shadow: 0 1px 3px rgba(0,0,0,.07); transition: box-shadow .15s; }
.order-card:hover { box-shadow: 0 3px 8px rgba(0,0,0,.12); }
.task-card { border-left-color: #10b981; }
.order-card-num { font-size: .75rem; color: #6b7280; margin-bottom: 2px; }
.order-card-title { font-weight: 600; font-size: .875rem; margin-bottom: 4px; }
.order-card-meta { display: flex; justify-content: space-between; font-size: .78rem; color: #6b7280; }
.order-card-deadline { font-size: .72rem; color: #9ca3af; margin-top: 4px; }

/* ===== TABS ===== */
.tab-bar, .order-tabs, .client-tabs { display: flex; gap: 0; border-bottom: 2px solid #e5e7eb; margin-bottom: 16px; }
.tab-btn { padding: 9px 16px; font-size: .875rem; font-weight: 500; color: #6b7280;
  cursor: pointer; border: none; background: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all .15s; }
.tab-btn:hover { color: #374151; }
.tab-btn.active { color: #4f46e5; border-bottom-color: #4f46e5; font-weight: 600; }
.tab-content { display: block; }
.tab-content.hidden { display: none; }

/* ===== TOOLBAR ===== */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.orders-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.view-toggle { display: flex; gap: 4px; }

/* ===== STATS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.07); }
.stat-label { font-size: .75rem; color: #6b7280; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: #1a1a2e; margin: 6px 0 2px; }

/* ===== FINANCE / CASHBOXES ===== */
.cashbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.cashbox-card { background: #fff; border-radius: 10px; padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07); border-top: 4px solid #4f46e5; }
.cashbox-add { border: 2px dashed #e5e7eb; border-top: none; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  color: #9ca3af; cursor: pointer; min-height: 140px; border-radius: 10px;
  transition: background .15s; }
.cashbox-add:hover { background: #f9fafb; }
.cashbox-name { font-weight: 700; font-size: .95rem; margin-bottom: 8px; }
.cashbox-balance { font-size: 1.4rem; font-weight: 800; color: #059669; margin-bottom: 4px; }
.cashbox-type { font-size: .78rem; color: #9ca3af; }
.cashbox-actions { display: flex; gap: 8px; margin-top: 12px; }

/* master-detail layout */
.fin-master-detail { display: flex; gap: 0; height: calc(100vh - 130px); overflow: hidden; }
.fin-sidebar { width: 280px; min-width: 240px; background: #fff; border-radius: 10px;
  border: 1px solid #e5e7eb; overflow-y: auto; flex-shrink: 0; padding: 8px 0; }
.fin-detail { flex: 1; overflow-y: auto; padding: 0 0 0 16px; }
.cb-group { margin-bottom: 4px; }
.cb-group-header { display: flex; justify-content: space-between; padding: 8px 16px 4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.cb-list-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  cursor: pointer; transition: background .12s; border-radius: 0; }
.cb-list-item:hover { background: #f9fafb; }
.cb-list-item.active { background: #eff6ff; }
.cb-list-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cb-list-info { flex: 1; min-width: 0; }
.cb-list-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-list-sub { font-size: 11px; color: #9ca3af; }
.cb-list-balance { font-weight: 700; font-size: 13px; color: #059669; white-space: nowrap; }
.cb-total-row { display: flex; justify-content: space-between; padding: 10px 16px;
  border-top: 1px solid #e5e7eb; font-weight: 700; font-size: 13px; margin-top: 4px; }
.fin-detail-header { display: flex; justify-content: space-between; align-items: flex-start;
  background: #fff; border-radius: 10px; padding: 16px 20px; margin-bottom: 16px;
  border: 1px solid #e5e7eb; }
.fin-detail-balance { font-size: 1.6rem; font-weight: 800; color: #059669; }
.tx-row:hover { background: #f9fafb; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 560px;
  max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-wide   { max-width: 860px; height: 88vh; }
.modal-narrow { max-width: 420px; }
.modal-header { display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }
.modal-header span { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; color: #6b7280; font-size: 1.2rem; padding: 4px; border-radius: 4px; }
.modal-close:hover { background: #f3f4f6; color: #374151; }
.modal-back-btn { background: none; border: none; color: #3b82f6; font-size: 0.85rem; padding: 4px 8px 4px 0; cursor: pointer; margin-right: 8px; white-space: nowrap; }
.modal-back-btn:hover { color: #1d4ed8; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

/* ===== TOAST ===== */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: #1a1a2e; color: #fff; padding: 12px 18px; border-radius: 8px;
  font-size: .875rem; box-shadow: 0 4px 12px rgba(0,0,0,.2); max-width: 320px;
  opacity: 0; transform: translateX(100%); transition: all .25s; pointer-events: auto; }
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { background: #059669; }
.toast-error   { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info    { background: #1a1a2e; }

/* ===== SEARCH RESULTS ===== */
.search-result-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f3f4f6;
  font-size: .875rem; transition: background .1s; }
.search-result-item:hover { background: #f3f4f6; }

/* ===== LIST ITEMS (sidebar lists) ===== */
.list-item { cursor: pointer; transition: background .15s; }
.list-item:hover { background: #f9fafb; }
.list-item.active { background: #ede9fe; color: #4f46e5; }

/* ===== PRODUCT PICKER TABS ===== */
.bps-tab { background: transparent; border: 1px solid #e5e7eb; color: #374151; }
.bps-tab:hover { background: #f3f4f6; }
.bps-tab-active { background: #4f46e5 !important; border-color: #4f46e5 !important; color: #fff !important; }

/* ===== PAGINATION ===== */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pagination .btn { min-width: 34px; }
.pagination .btn.active { background: #4f46e5; color: #fff; border-color: #4f46e5; }
.pagination span { color: #9ca3af; padding: 0 2px; }

/* ===== MISC ===== */
.empty-state { text-align: center; padding: 48px 20px; color: #9ca3af; }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; }
.spinner { width: 24px; height: 24px; border: 3px solid #e5e7eb;
  border-top-color: #4f46e5; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.text-success { color: #059669; }
.text-danger  { color: #ef4444; }
.text-muted   { color: #9ca3af; }
.fw-bold      { font-weight: 700; }
.clickable    { cursor: pointer; }

/* ===== SIDEBAR OVERLAY (mobile) ===== */
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 150; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .dialogs-layout { grid-template-columns: 280px 1fr; }
  .dialog-client-panel { display: none; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; height: 100vh; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .burger-btn { display: flex; }
  .dialogs-layout { grid-template-columns: 1fr; }
  .dialogs-sidebar { display: none; }
}
@media (max-width: 640px) {
  .content { padding: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban-board { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-box { margin: 10px; }
}

/* ===== AI FEEDBACK ===== */
.ai-fb-btns { display: flex; gap: 4px; margin-top: 3px; }
.ai-fb-btns button { background: none; border: none; cursor: pointer; padding: 2px 4px; font-size: 13px; opacity: .5; transition: opacity .15s; border-radius: 4px; }
.ai-fb-btns button:hover { opacity: 1; background: #f3f4f6; }

/* ===== ATTACH CARDS ===== */
.attach-card { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px;
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3); cursor: pointer; font-size: 12px;
  white-space: nowrap; transition: background .15s; }
.attach-card:hover { background: rgba(255,255,255,.25); }
.msg-in .attach-card { background: #f3f4f6; border-color: #e5e7eb; color: #374151; }
.msg-in .attach-card:hover { background: #e5e7eb; }

/* ===== TEAM CHAT PANEL ===== */
@keyframes tchat-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(99,102,241,.7); }
  70%  { box-shadow: 0 0 0 8px rgba(99,102,241,0); }
  100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
