/* ============ Reset & base ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin:0; height:100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
  color: #0f172a;
  background: #f8fafc;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  text-rendering: optimizeLegibility;
}
button { font: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color:#64748b; }
.small { font-size:12px; }
.err { color:#dc2626; font-size:13px; min-height:18px; font-weight: 500; }
::selection { background: rgba(153,27,27,0.22); color:#7f1d1d; }
[data-theme="dark"] ::selection { background: rgba(220,38,38,0.35); color:#fef2f2; }
kbd { background:#f1f5f9; border:1px solid #cbd5e1; border-bottom-width:2px; border-radius:4px;
  padding:1px 5px; font-size:11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color:#0f172a; }
code { background:#fef2f2; color:#991b1b; padding:1px 6px; border-radius:4px; font-size:12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ============ Login ============ */
#login-view {
  min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(127,29,29,0.18), transparent 70%),
    linear-gradient(135deg, #0a0a0b 0%, #150202 60%, #1a0303 100%);
  position:relative; overflow:hidden;
}
.login-stage {
  position: relative; z-index: 10;
  display:flex; flex-direction:column; align-items:center;
  width:100%; max-width:420px; gap: 18px;
}
.login-hero {
  display:flex; align-items:center; justify-content:center;
  width:100%;
  opacity:0; transform: translateY(-12px);
  animation: hero-in .7s cubic-bezier(.2,.9,.3,1.1) .05s forwards;
}
.login-logo {
  display:block;
  width: 78%; max-width: 280px; max-height: 130px;
  object-fit: contain;
  filter: drop-shadow(0 14px 32px rgba(220,38,38,0.45));
  animation: logo-float 4.5s ease-in-out infinite;
}
@keyframes hero-in { to { opacity:1; transform: translateY(0); } }
@keyframes logo-float {
  0%, 100% { transform: translateY(0); filter: drop-shadow(0 14px 32px rgba(220,38,38,0.45)); }
  50%      { transform: translateY(-4px); filter: drop-shadow(0 18px 40px rgba(220,38,38,0.6)); }
}
.login-bg-blob {
  position:absolute; border-radius:50%; filter: blur(70px); opacity:.5; pointer-events:none;
  will-change: transform;
}
.blob-a { width:480px; height:480px; background:#dc2626; top:-160px; left:-160px;
  animation: blob-float-a 18s ease-in-out infinite alternate; }
.blob-b { width:520px; height:520px; background:#7f1d1d; bottom:-200px; right:-200px;
  animation: blob-float-b 22s ease-in-out infinite alternate; }
.blob-c { width:340px; height:340px; background:#991b1b; top:50%; left:60%;
  opacity:.3; animation: blob-float-c 26s ease-in-out infinite alternate; }
@keyframes blob-float-a { 0% { transform: translate(0,0) scale(1);} 100% { transform: translate(80px,100px) scale(1.15);} }
@keyframes blob-float-b { 0% { transform: translate(0,0) scale(1);} 100% { transform: translate(-100px,-60px) scale(.95);} }
@keyframes blob-float-c { 0% { transform: translate(-50%,-50%) scale(1);} 100% { transform: translate(-30%,-70%) scale(1.2);} }

.login-card {
  position:relative; z-index:10;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(10px);
  padding:38px 34px 28px; border-radius:20px; width:100%; max-width:420px;
  box-shadow: 0 25px 70px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.06);
  display:flex; flex-direction:column; gap:6px;
  opacity:0; transform: translateY(24px) scale(.96);
  animation: card-in .7s cubic-bezier(.2,.9,.3,1.1) .1s forwards;
}
@keyframes card-in { to { opacity:1; transform: translateY(0) scale(1); } }

.login-sub { margin: 2px 0 14px; text-align:center; font-size:13px; color:#64748b; }
.login-card label { font-size:12px; font-weight:600; margin-top:10px; color:#475569; }
.login-card input {
  padding:12px 14px; border:1px solid #e2e8f0; border-radius:11px;
  font:inherit; outline:none; background:#f8fafc;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.login-card input:focus { border-color:#991b1b; box-shadow: 0 0 0 3px rgba(153,27,27,0.14); background:white; }

.login-card button {
  margin-top:20px; padding:13px 16px;
  background: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 100%);
  color:white; border:0; border-radius:11px;
  font-weight:600; font-size:14.5px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:8px;
  position:relative; overflow:hidden;
  box-shadow: 0 8px 20px rgba(127,29,29,0.35);
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.login-card button .btn-arrow { transition: transform .25s ease; display:inline-block; }
.login-card button:hover { filter: brightness(1.08); transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(127,29,29,0.45); }
.login-card button:hover .btn-arrow { transform: translateX(4px); }
.login-card button:active { transform: translateY(0); }

.login-footer { margin-top:14px; text-align:center; font-size:11px; color:#94a3b8; letter-spacing:.5px; }
.brand-rauf {
  font-weight:700; letter-spacing:.3px;
  background: linear-gradient(90deg, #dc2626 0%, #f97316 22%, #fbbf24 50%, #f97316 78%, #dc2626 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: rauf-shimmer 4s linear infinite;
}
@keyframes rauf-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============ App layout ============ */
#app-view { display: grid; grid-template-columns: 60px 280px 1fr 300px; height: 100vh; background: #f1f5f9; }

/* ============ Sidebar Rail ============ */
.sidebar-rail {
  background: linear-gradient(180deg, #08080a 0%, #050506 100%);
  border-right: 1px solid rgba(255,255,255,0.05);
  display:flex; flex-direction:column; align-items:center;
  padding: 14px 0 12px;
}
.rail-brand { margin-bottom: 12px; padding: 4px; }
.rail-brand img { display:block; width: 34px; height: 34px; object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(220,38,38,0.4)); }
.rail-nav, .rail-utils { display:flex; flex-direction:column; gap:2px; align-items:center;
  width: 100%; padding: 0 6px; }
.rail-spacer { flex:1; }
.rail-btn {
  width: 42px; height: 42px; border-radius: 10px;
  background: transparent; border: 0; cursor: pointer;
  color: #71717a; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: background .18s, color .18s, transform .1s;
  position: relative;
}
.rail-btn svg { width: 20px; height: 20px; }
.rail-btn:hover { background: rgba(255,255,255,0.06); color: #f1f5f9; }
.rail-btn.active { background: linear-gradient(135deg, rgba(220,38,38,0.22), rgba(220,38,38,0.06));
  color: #fca5a5; box-shadow: inset 0 0 0 1px rgba(220,38,38,0.35); }
.rail-btn.active::before {
  content: ''; position: absolute; left: -6px; top: 8px; bottom: 8px;
  width: 3px; background: #dc2626; border-radius: 0 3px 3px 0;
}
.rail-btn:active { transform: scale(0.94); }
.rail-btn.me-logout:hover { background: rgba(220,38,38,0.18); color: #fca5a5; }
.rail-badge {
  position:absolute; top: 4px; right: 4px;
  background: #22c55e; color: white;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px #08080a;
}

/* Sidebar section switching */
.sidebar-section { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.sidebar-section.hidden { display: none; }
.sidebar-header { padding: 16px 16px 6px; }
.section-title { color: white; font-size: 15px; font-weight: 700; letter-spacing:-.2px;
  display: flex; align-items: center; gap: 8px; }
.section-sub { color: #71717a; font-size: 11.5px; margin-top: 2px; }
.section-count { background: rgba(220,38,38,0.18); color: #fca5a5;
  padding: 1px 8px; height: 18px; border-radius: 9px;
  font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; }

/* Traffic items */
.traffic-item {
  padding: 11px 12px; margin: 2px 0; border-radius: 10px; cursor: pointer;
  display: flex; gap: 11px; align-items: flex-start;
  border-left: 2px solid transparent;
  transition: background .18s;
}
.traffic-item:hover { background: rgba(255,255,255,0.03); }
.traffic-item.active { background: linear-gradient(90deg, rgba(220,38,38,0.14) 0%, rgba(220,38,38,0.02) 100%);
  border-left-color: #dc2626; }
.traffic-item.no-conv { cursor: default; }
.traffic-item.no-conv:hover { background: rgba(255,255,255,0.02); }
.traffic-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #71717a;
  flex-shrink: 0; margin-top: 15px; }
.traffic-status-dot.chatting { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.6); }
.traffic-status-dot.browsing { background: #3b82f6; box-shadow: 0 0 6px rgba(59,130,246,0.5); }

/* Team page */
.team-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.team-add-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: white; font-size: 18px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(220,38,38,0.25);
  transition: transform .15s ease, box-shadow .15s ease;
  flex-shrink: 0; margin-top: 4px;
}
.team-add-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(220,38,38,0.35); }
.team-add-btn:active { transform: translateY(0); }

.team-item { position: relative; }
.team-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #71717a;
  flex-shrink: 0; margin-top: 15px; }
.team-status-dot.online { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.6); }
.team-status-dot.away { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.55); }
.team-status-dot.offline { background: #52525b; }
.team-role-pill {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
  padding: 1px 7px; border-radius: 999px; height: 16px;
  display: inline-flex; align-items: center;
}
.team-role-pill.admin { background: rgba(220,38,38,0.16); color: #fca5a5; border: 1px solid rgba(220,38,38,0.3); }
.team-role-pill.agent { background: rgba(59,130,246,0.16); color: #93c5fd; border: 1px solid rgba(59,130,246,0.3); }
.team-menu-btn {
  position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; border-radius: 6px; background: transparent;
  border: none; color: #a1a1aa; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
  opacity: 0; transition: opacity .15s ease, background .15s ease;
}
.team-item:hover .team-menu-btn { opacity: 1; }
.team-menu-btn:hover { background: rgba(255,255,255,0.06); color: #f4f4f5; }
.team-menu-btn.open { opacity: 1; background: rgba(255,255,255,0.08); color: #f4f4f5; }
.team-menu {
  position: absolute; top: 34px; right: 8px; min-width: 168px;
  background: #18181b; border: 1px solid rgba(255,255,255,0.08); border-radius: 8px;
  padding: 4px; box-shadow: 0 12px 32px rgba(0,0,0,0.55);
  z-index: 20;
}
.team-menu button {
  width: 100%; text-align: left; padding: 8px 12px; border-radius: 6px;
  background: transparent; border: none; color: #e5e7eb; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
}
.team-menu button:hover { background: rgba(255,255,255,0.06); }
.team-menu button.danger { color: #f87171; }
.team-menu button.danger:hover { background: rgba(220,38,38,0.14); }
.team-menu-sep { height: 1px; background: rgba(255,255,255,0.06); margin: 4px 2px; }

/* Utility */
.admin-only.hidden { display: none !important; }
.rail-btn.hidden { display: none; }

/* Team menu button — always visible on touch/keyboard-focus; hover-reveal on desktop */
.team-menu-btn:focus-visible { opacity: 1; outline: 2px solid #dc2626; outline-offset: 2px; }
@media (hover: none), (pointer: coarse) { .team-menu-btn { opacity: 1; } }

/* Primary CTA gradient — applies to shortcut, agent-add, and reset-password Save buttons */
#sc-save, #agent-save, #reset-pw-go {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%) !important;
  color: white !important; border: none !important;
  box-shadow: 0 4px 12px rgba(220,38,38,0.22);
}
#sc-save:hover, #agent-save:hover, #reset-pw-go:hover { filter: brightness(1.08); }

/* ============ Chat compose mode tabs (Reply / Internal Note) ============ */
.mode-tabs {
  display: flex; gap: 6px; padding: 8px 16px 0;
  border-bottom: none;
}
.mode-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px 8px 0 0;
  background: transparent; border: 1px solid transparent; border-bottom: none;
  color: #71717a; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background .12s, color .12s;
}
.mode-tab:hover { color: #e5e7eb; background: rgba(255,255,255,0.04); }
.mode-tab.active[data-mode="reply"] {
  color: #dc2626; background: rgba(220,38,38,0.08);
  border-color: rgba(220,38,38,0.2);
}
.mode-tab.active[data-mode="note"] {
  color: #d97706; background: rgba(245,158,11,0.12);
  border-color: rgba(245,158,11,0.3);
}
body:not([data-theme="dark"]) .mode-tab { color: #6b7280; }
body:not([data-theme="dark"]) .mode-tab:hover { color: #111827; background: rgba(0,0,0,0.03); }

/* Note-mode input restyling */
.chat-footer.note-mode {
  background: linear-gradient(180deg, rgba(245,158,11,0.06) 0%, rgba(245,158,11,0.02) 100%);
}
.chat-footer.note-mode #msg-input {
  background: rgba(245,158,11,0.08);
  border-color: rgba(245,158,11,0.35) !important;
  color: inherit;
}
.chat-footer.note-mode #send-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
}

/* ============ Note messages (internal only) ============ */
.msg.note-msg {
  margin-left: auto; max-width: 80%;
  background: linear-gradient(180deg, rgba(245,158,11,0.14) 0%, rgba(245,158,11,0.08) 100%);
  border: 1px dashed rgba(245,158,11,0.5);
  color: #78350f;
  padding: 10px 14px; border-radius: 12px;
  position: relative;
}
body[data-theme="dark"] .msg.note-msg,
@media (prefers-color-scheme: dark) { .msg.note-msg { color: #fde68a; } }
.msg.note-msg::before {
  content: '🔒 İç not — ' attr(data-sender);
  display: block; font-size: 10.5px; font-weight: 700;
  letter-spacing: .3px; text-transform: uppercase;
  opacity: 0.8; margin-bottom: 4px;
}

/* ============ Supervise-mode banner in chat header ============ */
.supervise-banner {
  background: linear-gradient(180deg, rgba(245,158,11,0.14) 0%, rgba(245,158,11,0.06) 100%);
  border-bottom: 1px solid rgba(245,158,11,0.3);
  padding: 8px 16px; font-size: 12.5px; font-weight: 500;
  color: #d97706; display: flex; align-items: center; gap: 8px;
}
.supervise-banner::before { content: '👁'; font-size: 15px; }
body[data-theme="dark"] .supervise-banner,
@media (prefers-color-scheme: dark) { .supervise-banner { color: #fbbf24; } }
.supervise-banner.hidden { display: none; }

/* Popover (chat transfer) */
.popover {
  position: fixed; z-index: 1000; min-width: 260px; max-width: 320px;
  background: #ffffff; color: #1f2937;
  border: 1px solid rgba(0,0,0,0.06); border-radius: 12px;
  box-shadow: 0 20px 48px rgba(0,0,0,0.18), 0 4px 14px rgba(0,0,0,0.08);
  padding: 12px;
  animation: pop-in .14s ease-out;
}
.popover.hidden { display: none; }
@keyframes pop-in { from { opacity:0; transform: translateY(-4px) scale(.98); } to { opacity:1; transform: translateY(0) scale(1); } }
.popover-arrow {
  position: absolute; top: -6px; right: 20px;
  width: 12px; height: 12px; background: #ffffff;
  border-left: 1px solid rgba(0,0,0,0.06); border-top: 1px solid rgba(0,0,0,0.06);
  transform: rotate(45deg);
}
.popover-title { font-size: 13px; font-weight: 700; color: #111827; padding: 2px 6px 0; }
.popover-sub { font-size: 11.5px; color: #6b7280; padding: 2px 6px 8px; }
.popover-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.popover-list .empty-list { padding: 10px 8px; color: #9ca3af; font-size: 12.5px; }
.transfer-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px; border-radius: 8px;
  background: transparent; border: none; cursor: pointer; text-align: left;
  transition: background .12s;
}
.transfer-item:hover { background: rgba(0,0,0,0.05); }
.transfer-item:disabled { opacity: 0.5; cursor: not-allowed; }
.transfer-item .conv-avatar { width: 32px; height: 32px; font-size: 12px; }
.ti-info { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.ti-name { font-size: 13px; font-weight: 600; color: #111827; }
.ti-status { font-size: 11px; color: #6b7280; display: flex; align-items: center; gap: 5px; }
.ti-status::before { content:''; width: 6px; height: 6px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 5px rgba(34,197,94,0.6); }
.ti-status.away::before { background: #f59e0b; box-shadow: 0 0 5px rgba(245,158,11,0.55); }

/* Dark mode for popover */
body[data-theme="dark"] .popover,
@media (prefers-color-scheme: dark) {
  .popover { background: #1e1e22; color: #e5e7eb; border-color: rgba(255,255,255,0.08); }
  .popover-arrow { background: #1e1e22; border-color: rgba(255,255,255,0.08); }
  .popover-title { color: #f4f4f5; }
  .popover-sub { color: #a1a1aa; }
  .transfer-item:hover { background: rgba(255,255,255,0.06); }
  .ti-name { color: #f4f4f5; }
  .ti-status { color: #a1a1aa; }
}

/* Toast stack */
.toast-stack {
  position: fixed; bottom: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  background: #111827; color: #f9fafb; padding: 10px 14px;
  border-radius: 10px; font-size: 13px; font-weight: 500;
  box-shadow: 0 14px 32px rgba(0,0,0,0.35), 0 3px 10px rgba(0,0,0,0.18);
  border-left: 3px solid #22c55e;
  max-width: 340px; min-width: 240px;
  animation: toast-in .22s ease-out;
  pointer-events: auto;
}
.toast.info { border-left-color: #3b82f6; }
.toast.warn { border-left-color: #f59e0b; }
.toast.error { border-left-color: #ef4444; }
.toast.fade { opacity: 0; transform: translateX(8px); transition: opacity .22s ease, transform .22s ease; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============ Sidebar ============ */
.sidebar {
  background: linear-gradient(180deg, #0d0d0f 0%, #0a0a0c 100%);
  color: #e5e7eb; display:flex; flex-direction:column;
  border-right: 1px solid rgba(255,255,255,0.05);
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.02);
}
.brand { padding: 18px 16px 14px; display:flex; align-items:center; justify-content:center;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: radial-gradient(circle at 50% 0%, rgba(220,38,38,0.08), transparent 70%); }
.brand-logo { display:block; max-width: 100%; max-height: 44px; object-fit: contain;
  filter: drop-shadow(0 4px 14px rgba(220,38,38,0.35));
  transition: filter .3s ease; }
.brand:hover .brand-logo { filter: drop-shadow(0 6px 20px rgba(220,38,38,0.5)); }

.search-box { padding: 14px 14px 10px; position:relative; }
.search-icon { position:absolute; left:26px; top:50%; transform:translateY(-40%); color:#71717a; font-size:14px; pointer-events:none; }
.search-box input {
  width:100%; padding: 10px 12px 10px 34px;
  border:1px solid rgba(255,255,255,0.06); border-radius:10px;
  background:rgba(255,255,255,0.03); color:#e5e7eb; font:inherit; outline:none;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.search-box input::placeholder { color:#71717a; }
.search-box input:focus { border-color:rgba(220,38,38,0.5); background:rgba(220,38,38,0.06);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.1); }

.sidebar-tabs { display:flex; padding: 4px 10px 10px; gap: 4px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.sidebar-tabs .tab {
  flex:1; background:transparent; border:0; padding:8px 8px;
  font-size:11px; font-weight:600; text-transform: uppercase; letter-spacing:.5px;
  color:#71717a; cursor:pointer; border-radius:7px;
  display:flex; align-items:center; justify-content:center; gap:5px;
  transition: background .18s, color .18s;
}
.sidebar-tabs .tab:hover { background:rgba(255,255,255,0.04); color:#e5e7eb; }
.sidebar-tabs .tab.active { background: linear-gradient(135deg, rgba(220,38,38,0.18), rgba(220,38,38,0.08));
  color:#fca5a5; box-shadow: inset 0 0 0 1px rgba(220,38,38,0.2); }
.tab-count { background: rgba(220,38,38,0.18); color:#fca5a5;
  padding: 0 6px; height:16px; min-width:16px; border-radius:8px;
  font-size:10px; display:inline-flex; align-items:center; justify-content:center; }
.sidebar-tabs .tab.active .tab-count { background: rgba(220,38,38,0.3); }

.conv-list { flex:1; overflow-y:auto; padding: 8px 6px; }
.conv-list::-webkit-scrollbar { width:6px; }
.conv-list::-webkit-scrollbar-thumb { background:rgba(255,255,255,0.06); border-radius:4px; }
.conv-list::-webkit-scrollbar-thumb:hover { background:rgba(255,255,255,0.12); }

.conv-item {
  padding: 11px 12px; margin: 2px 0; border-radius: 10px; cursor:pointer;
  display:flex; gap:11px; align-items:flex-start;
  border-left: 2px solid transparent;
  transition: background .18s, border-color .18s, transform .12s;
  position:relative;
}
.conv-item:hover { background: rgba(255,255,255,0.03); }
.conv-item:active { transform: scale(0.99); }
.conv-item.active { background: linear-gradient(90deg, rgba(220,38,38,0.14) 0%, rgba(220,38,38,0.02) 100%);
  border-left-color: #dc2626; box-shadow: inset 0 0 0 1px rgba(220,38,38,0.15); }
.conv-avatar { width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color:white; font-weight:700; font-size:14px; letter-spacing:.3px;
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3); }
.conv-avatar.tone-1 { background: linear-gradient(135deg,#dc2626,#7f1d1d); }
.conv-avatar.tone-2 { background: linear-gradient(135deg,#2563eb,#1e40af); }
.conv-avatar.tone-3 { background: linear-gradient(135deg,#16a34a,#14532d); }
.conv-avatar.tone-4 { background: linear-gradient(135deg,#ea580c,#7c2d12); }
.conv-avatar.tone-5 { background: linear-gradient(135deg,#7c3aed,#4c1d95); }
.conv-avatar.tone-6 { background: linear-gradient(135deg,#0891b2,#155e75); }
.conv-meta { flex:1; min-width:0; }
.conv-top { display:flex; align-items:center; justify-content:space-between; gap:6px; }
.conv-name { color:#f3f4f6; font-weight:600; font-size:13.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.conv-time { color:#71717a; font-size:11px; flex-shrink:0; }
.conv-preview { color:#9ca3af; font-size:12.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }
.conv-badges { display:flex; gap:4px; margin-top:4px; flex-wrap:wrap; }
.conv-pill { display:inline-block; padding:1px 7px; border-radius:999px; font-size:10px; font-weight:600; letter-spacing:.3px; }
.pill-new { background: rgba(234,179,8,0.18); color:#fde68a; }
.pill-mine { background: rgba(34,197,94,0.16); color:#86efac; }
.pill-closed { background: rgba(148,163,184,0.18); color:#cbd5e1; }
.pill-archived { background: rgba(148,163,184,0.18); color:#cbd5e1; }
.conv-unread { background: #dc2626; color:white; min-width:18px; height:18px; padding:0 5px; border-radius:9px;
  font-size:10px; font-weight:700; display:flex; align-items:center; justify-content:center; }
.empty-list { padding: 30px 16px; text-align:center; color:#6b7280; font-size:12.5px; }

.search-meta { padding: 8px 16px; font-size:11px; color:#9ca3af; background:#0e0e10; border-bottom:1px solid #1f1f23; }
.search-meta .search-clear { color:#fca5a5; text-decoration:none; }
.search-meta .search-clear:hover { text-decoration:underline; }
mark { background: rgba(251,191,36,0.30); color:inherit; padding: 0 2px; border-radius: 3px; font-weight: 600; }
.conv-pill.pill-match { background: rgba(251,191,36,0.25); color: #fbbf24; text-transform: none; letter-spacing: .2px; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.05);
  padding: 12px 14px;
  display:flex; flex-direction:column; gap:10px;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.2) 100%);
}
.me { display:flex; align-items:center; gap:11px; padding: 4px 2px; }
.me-avatar { width:36px; height:36px; border-radius:50%;
  background: linear-gradient(135deg,#dc2626,#7f1d1d);
  color:white; font-weight:700; font-size:13px; letter-spacing:.3px;
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
  box-shadow: 0 3px 8px rgba(127,29,29,0.35); }
.me-meta { flex:1; min-width:0; line-height:1.3; }
.me-name { color:white; font-weight:600; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.me-status { background:transparent; border:0; cursor:pointer;
  color:#9ca3af; font-size:11px; display:inline-flex; align-items:center; gap:5px;
  margin: 1px 0 0 -6px; padding: 2px 8px; border-radius: 6px;
  font: inherit; font-size:11px;
  transition: background .15s, color .15s; }
.me-status:hover { background:rgba(255,255,255,0.06); color:#e5e7eb; }
.dot { width:7px; height:7px; border-radius:50%; background:#71717a; display:inline-block;
  transition: background .18s, box-shadow .18s; }
.dot.online { background:#22c55e; box-shadow: 0 0 8px rgba(34,197,94,0.6); }
.dot.away { background:#f59e0b; box-shadow: 0 0 8px rgba(245,158,11,0.6); }
.icon-btn {
  background:transparent; border:0; cursor:pointer;
  width:32px; height:32px; border-radius:8px;
  color:#9ca3af; font-size:14px;
  display:flex; align-items:center; justify-content:center;
  transition: background .18s, color .18s, transform .1s;
}
.icon-btn:hover { background:rgba(255,255,255,0.08); color:white; }
.icon-btn:active { transform: scale(0.94); }
.me-actions {
  display:flex; align-items:center; gap:2px;
  background:rgba(0,0,0,0.35); border:1px solid rgba(255,255,255,0.06);
  border-radius:11px; padding:4px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}
.me-actions .icon-btn { width:32px; height:30px; font-size:13px; padding:0; }
.me-actions .me-spacer { flex:1; }
.me-actions .me-logout:hover { background: rgba(220,38,38,0.2); color:#fca5a5; }
.powered-by { text-align:center; font-size:10.5px; color:#52525b; letter-spacing:.5px; padding-top:4px; }

/* ============ Chat area ============ */
.chat { background: #f8fafc;
  background-image: radial-gradient(circle at 100% 0%, rgba(220,38,38,0.03) 0%, transparent 50%),
                    radial-gradient(circle at 0% 100%, rgba(37,99,235,0.03) 0%, transparent 50%);
  display:flex; flex-direction:column; min-width:0; }
.empty { flex:1; display:flex; align-items:center; justify-content:center; flex-direction:column;
  color:#64748b; text-align:center; padding: 40px; gap:16px; }
.empty-illustration { position:relative; width:120px; height:120px;
  display:flex; align-items:center; justify-content:center; margin-bottom:6px; }
.empty-illustration svg { width:72px; height:72px; color:#dc2626; opacity:.35; z-index:2; position:relative; }
.empty-ring { position:absolute; inset:0; border-radius:50%;
  border:2px solid rgba(220,38,38,0.15);
  animation: empty-pulse 3s ease-out infinite; }
.empty-ring.ring-2 { animation-delay:1.5s; }
@keyframes empty-pulse {
  0% { transform: scale(.6); opacity:.8; }
  100% { transform: scale(1.2); opacity:0; }
}
.empty h2 { margin:0; color:#0f172a; font-size:20px; font-weight:700; letter-spacing:-.3px; }
.empty p { margin:0; max-width:360px; font-size:14px; color:#64748b; line-height:1.6; }
#chat-view { flex:1; display:flex; flex-direction:column; min-height:0;
  animation: view-in .3s ease-out; }
@keyframes view-in { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }

.chat-header { padding: 16px 24px; background:white;
  border-bottom: 1px solid #eef2f7;
  box-shadow: 0 1px 0 rgba(15,23,42,0.02), 0 4px 12px -8px rgba(15,23,42,0.08);
  display:flex; align-items:center; justify-content:space-between; z-index:5; position:relative; }
.chat-title { display:flex; align-items:center; gap:14px; min-width:0; }
.chat-avatar { width:44px; height:44px; border-radius:50%;
  background: linear-gradient(135deg,#dc2626,#7f1d1d);
  color:white; font-weight:700; font-size:15px; letter-spacing:.3px;
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
  box-shadow: 0 4px 12px rgba(127,29,29,0.25); }
.chat-title-text h2 { margin:0; font-size:16px; font-weight:600; color:#0f172a; letter-spacing:-.2px; }
.chat-status { font-size:12px; color:#64748b; display:flex; align-items:center; gap:6px; margin-top:2px; }
.chat-status .status-dot { width:7px; height:7px; border-radius:50%; background:#94a3b8; }
.chat-status .status-dot.live { background:#22c55e; box-shadow: 0 0 8px rgba(34,197,94,0.6); animation: live-pulse 2s ease-out infinite; }
@keyframes live-pulse { 0%,100% { box-shadow: 0 0 8px rgba(34,197,94,0.6); } 50% { box-shadow: 0 0 12px rgba(34,197,94,0.9); } }
.chat-actions { display:flex; gap:6px; align-items:center; }
.btn-ghost {
  background:white; border:1px solid #eef2f7; cursor:pointer;
  width:36px; height:36px; border-radius:10px; color:#475569;
  display:flex; align-items:center; justify-content:center; font-size:15px;
  transition: background .18s, color .18s, border-color .18s, transform .1s, box-shadow .18s;
}
.btn-ghost:hover { background:#fef2f2; border-color:#fecaca; color:#991b1b;
  box-shadow: 0 2px 8px rgba(153,27,27,0.12); }
.btn-ghost:active { transform: translateY(1px); }
.btn-ghost.active { background:#fef2f2; border-color:#fecaca; color:#991b1b; }
.btn-ghost.danger:hover { background:#fef2f2; border-color:#fca5a5; color:#b91c1c; }
.btn-ghost.danger { color:#b91c1c; }
.btn-secondary {
  background:white; border:1px solid #eef2f7; padding:8px 16px; border-radius:10px;
  cursor:pointer; font-size:13px; color:#334155; font-weight:600;
  transition: background .18s, color .18s, border-color .18s, transform .1s;
}
.btn-secondary:hover { background:#fef2f2; color:#991b1b; border-color:#fecaca; }
.btn-secondary:active { transform: translateY(1px); }
.btn-secondary:disabled { opacity:.5; cursor:not-allowed; }
.danger-btn {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color:white; border:0; padding:9px 16px; border-radius:8px;
  font:inherit; cursor:pointer; font-weight:600; font-size:13px;
  box-shadow: 0 4px 10px rgba(153,27,27,0.25);
}
.danger-btn:hover { filter: brightness(1.08); }

.chat-body { flex:1; overflow-y:auto; padding: 24px 24px 20px;
  display:flex; flex-direction:column; gap:10px;
  background:
    radial-gradient(circle at 100% 0%, rgba(220,38,38,0.03) 0%, transparent 40%),
    linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%); }
.chat-body::-webkit-scrollbar { width:8px; }
.chat-body::-webkit-scrollbar-thumb { background:#cbd5e1; border-radius:4px; }
.chat-body::-webkit-scrollbar-thumb:hover { background:#94a3b8; }

.msg { max-width: 68%; padding: 11px 15px; border-radius: 18px;
  word-wrap: break-word; white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(15,23,42,0.05), 0 2px 8px rgba(15,23,42,0.04);
  font-size: 14px; line-height: 1.5;
  animation: msg-in .25s cubic-bezier(.2,.9,.3,1.1); }
@keyframes msg-in { from { opacity:0; transform: translateY(6px); } to { opacity:1; transform: translateY(0); } }
.msg.visitor { background:white; color:#0f172a; align-self:flex-start;
  border-bottom-left-radius:5px; border:1px solid #eef2f7; }
.msg.agent { color:white; align-self:flex-end;
  background: linear-gradient(135deg,#b91c1c 0%, #7f1d1d 100%);
  border-bottom-right-radius:5px;
  box-shadow: 0 4px 14px rgba(127,29,29,0.25), 0 1px 3px rgba(127,29,29,0.1); }
.msg.system { align-self:center; background:rgba(148,163,184,0.15); color:#64748b;
  font-size:11.5px; padding:5px 14px; border-radius:999px; box-shadow:none;
  font-weight:500; letter-spacing:.1px; }
.msg .meta { font-size:11px; opacity:.7; margin-top:4px; }
.msg.agent .meta { color: rgba(255,255,255,0.85); }
.msg .file-link { display:flex; align-items:center; gap:8px; padding:8px 10px; background:rgba(0,0,0,0.05);
  border-radius:8px; text-decoration:none; color:inherit; margin-top:4px; font-size:13px; }
.msg.agent .file-link { background:rgba(255,255,255,0.18); color:white; }
.msg .img { max-width:100%; border-radius:8px; display:block; margin-top:4px; }

.typing { align-self:flex-start; padding:10px 14px; background:white;
  border:1px solid #e2e8f0; border-radius:16px; border-bottom-left-radius:5px;
  display:none; gap:4px; }
.typing.on { display:flex; }
.typing span { width:6px; height:6px; background:#94a3b8; border-radius:50%; animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay:.15s; }
.typing span:nth-child(3) { animation-delay:.3s; }
@keyframes bounce { 0%,60%,100% { opacity:.3; transform:translateY(0);} 30% { opacity:1; transform:translateY(-4px);} }

.chat-footer { background:white; border-top:1px solid #eef2f7; padding: 16px 20px 18px;
  box-shadow: 0 -4px 12px -8px rgba(15,23,42,0.08); }
.attach-preview { display:flex; align-items:center; gap:8px; padding:8px 12px; background:#fef2f2;
  border:1px solid #fecaca; border-radius:8px; margin-bottom:10px; font-size:13px; color:#7f1d1d; }
.attach-preview button { margin-left:auto; background:transparent; border:0;
  cursor:pointer; color:#991b1b; font-size:18px; line-height:1; padding:0 4px; }
.attach-icon { font-size:14px; }
.input-row { display:flex; gap:8px; align-items:flex-end; }
.msg-wrap { flex:1; position:relative; }
.msg-wrap textarea { width:100%; resize:none;
  padding:12px 16px; border:1px solid #eef2f7; border-radius:12px;
  font:inherit; font-size:14px; outline:none; max-height:140px; min-height:44px;
  background:#f8fafc; color:#0f172a;
  transition: border-color .18s, background .18s, box-shadow .18s; }
.msg-wrap textarea:focus { border-color:#991b1b; background:white;
  box-shadow: 0 0 0 3px rgba(153,27,27,0.1); }
.msg-wrap textarea::placeholder { color:#94a3b8; }
#send-btn { background: linear-gradient(135deg,#b91c1c 0%, #7f1d1d 100%);
  color:white; border:0; padding:12px 22px; border-radius:12px;
  font-weight:600; cursor:pointer; font:inherit; font-size:14px;
  box-shadow: 0 6px 16px rgba(127,29,29,0.3), 0 2px 4px rgba(127,29,29,0.15);
  transition: filter .18s, transform .1s, box-shadow .18s;
  display:inline-flex; align-items:center; gap:5px; }
#send-btn:hover { filter: brightness(1.08); box-shadow: 0 8px 20px rgba(127,29,29,0.4); }
#send-btn:active { transform: translateY(1px); }
#send-btn:disabled { background:#e2e8f0; color:#94a3b8; box-shadow:none; cursor:not-allowed; filter:none; }
.input-hint { font-size:11px; color:#94a3b8; margin-top:8px; }

.sc-popup { position:absolute; bottom:calc(100% + 6px); left:0; right:0;
  background:white; border:1px solid #e2e8f0; border-radius:10px;
  box-shadow:0 16px 32px rgba(15,23,42,0.12);
  max-height:240px; overflow-y:auto; z-index:50; padding:4px; }
.sc-popup-item { padding:8px 10px; border-radius:6px; cursor:pointer; display:flex; flex-direction:column; gap:2px; }
.sc-popup-item.active, .sc-popup-item:hover { background:#fef2f2; }
.sc-popup-code { font-size:12px; color:#991b1b; font-weight:600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.sc-popup-title { font-size:13px; color:#0f172a; font-weight:600; }
.sc-popup-body { font-size:12px; color:#64748b; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* ============ Info panel ============ */
.info-panel { background: #f8fafc; border-left: 1px solid #eef2f7; overflow-y:auto;
  padding: 16px 14px; }
.info-panel::-webkit-scrollbar { width:6px; }
.info-panel::-webkit-scrollbar-thumb { background:#e2e8f0; border-radius:4px; }
.info-empty { padding: 40px 22px; text-align:center; color:#94a3b8;
  display:flex; flex-direction:column; align-items:center; gap:10px;
  height:100%; justify-content:center; background:transparent; }
.info-empty-icon { font-size:42px; opacity:.35; filter: grayscale(.2); }
.info-empty p { margin:0; font-size:13px; max-width:220px; line-height:1.6; }

.info-section {
  padding: 16px 18px; margin-bottom: 10px;
  background: white; border: 1px solid #eef2f7; border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
.info-section:first-child { text-align:center; padding: 22px 18px 18px; }
.info-section:last-child { margin-bottom: 0; }

.info-big-avatar { width:68px; height:68px; border-radius:50%; margin: 0 auto 10px;
  background: linear-gradient(135deg,#dc2626,#7f1d1d); color:white;
  display:flex; align-items:center; justify-content:center; font-weight:700; font-size:24px; letter-spacing:.3px;
  box-shadow: 0 10px 24px rgba(127,29,29,0.28), inset 0 -2px 4px rgba(0,0,0,0.15); }
.info-name { font-size:16px; font-weight:700; color:#0f172a; letter-spacing:-.1px; }
.info-email { font-size:12.5px; color:#64748b; margin-top:3px; }
.info-email a { color:#991b1b; text-decoration:none; font-weight:500; }
.info-email a:hover { text-decoration:underline; }
.info-pills { display:flex; flex-wrap:wrap; gap:5px; justify-content:center; margin-top:12px; }
.info-pill { font-size:10.5px; font-weight:700; letter-spacing:.4px; padding: 4px 10px; border-radius:999px;
  text-transform: uppercase; }
.info-pill.open { background:#dcfce7; color:#15803d; }
.info-pill.closed { background:#f1f5f9; color:#475569; }
.info-pill.archived { background:#fef3c7; color:#92400e; }
.info-pill.assigned { background:#fee2e2; color:#991b1b; }

.info-title { font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.7px;
  color:#94a3b8; margin-bottom:12px; display:flex; align-items:center; gap:6px; }
.info-title::after { content:''; flex:1; height:1px; background:#eef2f7; }
.info-row { display:flex; justify-content:space-between; gap:12px; padding: 8px 0;
  font-size:12.5px; align-items:baseline; }
.info-row + .info-row { border-top: 1px solid #f5f7fa; }
.info-label { color:#94a3b8; flex-shrink:0; font-weight:500; }
.info-value { color:#0f172a; text-align:right; min-width:0; overflow-wrap:anywhere; word-break:break-word;
  font-weight:500; }
.info-value.link, .info-value.link a { color:#991b1b; text-decoration:none; font-weight:600; }
.info-value.link a:hover { text-decoration:underline; }
#info-notes { width:100%; min-height:100px; padding:11px 13px;
  border:1px solid #eef2f7; border-radius:10px; font:inherit; font-size:13px; outline:none;
  background:#f8fafc; resize:vertical; color:#0f172a;
  transition: border-color .18s, background .18s, box-shadow .18s; }
#info-notes:focus { border-color:#991b1b; background:white; box-shadow: 0 0 0 3px rgba(153,27,27,0.1); }
#info-notes::placeholder { color:#94a3b8; }
.notes-status { font-size:11px; color:#94a3b8; margin-top:8px; min-height:14px; font-weight:500; }
.notes-status.saved { color:#16a34a; }

/* Extra answers */
#info-extra { display:flex; flex-direction:column; gap:8px; }
.extra-row { background:#f8fafc; border:1px solid #f1f5f9; border-radius:8px; padding:8px 10px; }
.extra-label { font-size:11px; font-weight:600; color:#64748b; margin-bottom:2px; }
.extra-value { font-size:13px; color:#0f172a; word-break:break-word; white-space:pre-wrap; }
.extra-value.bool { color:#16a34a; font-weight:600; }
.extra-value.bool.no { color:#94a3b8; }

/* ============ Modal ============ */
.modal { position:fixed; inset:0; z-index:1000; display:flex; align-items:center; justify-content:center; padding:20px; }
.modal-backdrop { position:absolute; inset:0; background:rgba(15,23,42,0.55); backdrop-filter: blur(2px); }
.modal-card { position:relative; background:white; border-radius:16px; padding:24px;
  width:100%; max-width:700px; max-height:90vh; overflow-y:auto;
  box-shadow:0 24px 64px rgba(0,0,0,0.3); border-top:4px solid #991b1b; }
.modal-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; }
.modal-head h2 { margin:0; font-size:18px; color:#0f172a; }
.modal-head .icon-btn { color:#475569; background:transparent; }
.modal-head .icon-btn:hover { background:#fef2f2; color:#991b1b; }

.sc-list { margin:14px 0; max-height:260px; overflow-y:auto;
  border:1px solid #e2e8f0; border-radius:10px; background:#f8fafc; }
.sc-list .sc-empty { padding:30px; text-align:center; color:#94a3b8; font-size:13px; }
.sc-item { display:flex; align-items:center; gap:12px; padding:10px 14px;
  border-bottom:1px solid #e2e8f0; background:white; }
.sc-item:first-child { border-top-left-radius:10px; border-top-right-radius:10px; }
.sc-item:last-child { border-bottom:0; border-bottom-left-radius:10px; border-bottom-right-radius:10px; }
.sc-item .sc-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size:12px; color:#991b1b; font-weight:600; min-width:96px;
  background:#fef2f2; padding:3px 8px; border-radius:6px; text-align:center; }
.sc-item .sc-info { flex:1; min-width:0; }
.sc-item .sc-title-line { font-weight:600; font-size:13px; color:#0f172a; }
.sc-item .sc-body-line { font-size:12px; color:#64748b; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sc-item-actions { display:flex; gap:4px; }
.sc-item-actions button { background:transparent; border:0; cursor:pointer;
  padding:5px 10px; border-radius:6px; font-size:12px; color:#475569; }
.sc-item-actions button:hover { background:#f1f5f9; color:#0f172a; }
.sc-item-actions .sc-del:hover { background:#fef2f2; color:#991b1b; }

.sc-form { display:flex; flex-direction:column; gap:10px; }
.sc-row { display:flex; gap:10px; }
.sc-field { display:flex; flex-direction:column; gap:4px; flex:1; }
.sc-field label { font-size:11px; font-weight:600; color:#475569; }
.sc-form input, .sc-form textarea, .sc-form select {
  padding:9px 11px; border:1px solid #e2e8f0; border-radius:8px;
  font:inherit; outline:none; background:#f8fafc;
}
.sc-form input:focus, .sc-form textarea:focus, .sc-form select:focus { border-color:#991b1b;
  box-shadow:0 0 0 3px rgba(153,27,27,0.08); background:white; }
.sc-form textarea { resize:vertical; min-height:80px; }
.sc-actions { display:flex; gap:8px; justify-content:flex-end; margin-top:4px; }
.sc-actions button { padding:9px 16px; border:0; border-radius:8px;
  font:inherit; cursor:pointer; font-weight:600; font-size:13px; }
#sc-save { background:linear-gradient(135deg,#991b1b 0%,#7f1d1d 100%); color:white;
  box-shadow: 0 4px 10px rgba(127,29,29,0.2); }
#sc-save:hover { filter: brightness(1.1); }

/* Ban card layout */
#ban-list { padding: 0; background:transparent; border:0; max-height:300px; }
.ban-card { background:white; border:1px solid #e2e8f0; border-radius:10px;
  padding:12px 14px; margin-bottom:8px; box-shadow: 0 1px 2px rgba(15,23,42,0.04); }
.ban-card:last-child { margin-bottom:0; }
.ban-card-items { display:flex; flex-direction:column; gap:6px; margin-bottom:10px; }
.ban-item-row { display:flex; align-items:center; gap:10px; }
.ban-type-pill { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.4px;
  padding:3px 8px; border-radius:5px; min-width:78px; text-align:center; flex-shrink:0; }
.ban-type-pill.ip { background:#fef3c7; color:#92400e; }
.ban-type-pill.visitor_id { background:#dbeafe; color:#1e40af; }
.ban-type-pill.email { background:#fce7f3; color:#9d174d; }
.ban-val-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size:12.5px; color:#0f172a; background:#f8fafc; padding:3px 8px;
  border-radius:5px; word-break:break-all; }
.ban-card-foot { display:flex; align-items:center; justify-content:space-between;
  gap:8px; border-top:1px dashed #e2e8f0; padding-top:8px; }
.ban-card-meta { font-size:12px; color:#64748b; flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; }
.ban-card-remove { background:transparent; border:1px solid #fecaca; color:#991b1b;
  padding:5px 12px; border-radius:6px; cursor:pointer; font-size:12px; font-weight:500;
  transition: background .15s; flex-shrink:0; }
.ban-card-remove:hover { background:#fef2f2; }
.ban-summary { background:#fef2f2; border:1px solid #fecaca; border-radius:8px;
  padding:10px 12px; margin: 10px 0 12px; font-size:13px; color:#7f1d1d; }
.ban-summary .ban-row { display:flex; justify-content:space-between; gap:8px; padding:3px 0; }
.ban-summary .ban-label { font-weight:600; color:#991b1b; }
.ban-summary .ban-val { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ============ Form builder ============ */
.fb-section { margin: 20px 0; padding-top: 4px; border-top: 1px solid #f1f5f9; }
.fb-section:first-of-type { margin-top: 12px; border-top: 0; padding-top: 0; }
.fb-section-title { font-size:10.5px; font-weight:700; text-transform:uppercase;
  letter-spacing:.7px; color:#64748b; margin: 12px 0 4px; }
.fb-section p.muted.small { margin: 0 0 12px; font-size:12px; line-height:1.5; }

.fb-section .sc-row { gap:10px; align-items:flex-start; }
.fb-section .sc-field input, .fb-section .sc-field textarea {
  padding: 8px 11px; font-size:13px;
  border:1px solid #e2e8f0; border-radius:8px;
  background:#f8fafc; outline:none; width:100%;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.fb-section .sc-field input:focus, .fb-section .sc-field textarea:focus {
  background:white; border-color:#991b1b; box-shadow: 0 0 0 3px rgba(153,27,27,0.08); }
.fb-section .sc-field label { font-size:11px; font-weight:600; color:#64748b; letter-spacing:.2px; margin-bottom: 4px; }

.fb-fields { display:flex; flex-direction:column; gap:6px; }
.fb-field-card { background:white; border:1px solid #e2e8f0; border-radius:9px;
  padding: 10px 12px; display:flex; flex-direction:column; gap:8px;
  transition: border-color .12s, box-shadow .12s; }
.fb-field-card:hover { border-color:#cbd5e1; box-shadow: 0 1px 4px rgba(15,23,42,0.04); }
.fb-field-card.system { background:#fffaf3; border-color:#fed7aa; }
.fb-field-card.disabled { opacity:.55; }

.fb-field-head { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.fb-type-pill { font-size:10px; font-weight:700; letter-spacing:.5px;
  padding:3px 8px; border-radius:5px; text-transform:uppercase;
  background:#e2e8f0; color:#334155; }
.fb-type-pill.system { background:#fed7aa; color:#9a3412; }
.fb-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size:11px; color:#94a3b8; letter-spacing:.2px; }
.fb-spacer { flex:1; }

.fb-move { background:transparent; border:1px solid #e2e8f0; border-radius:6px;
  cursor:pointer; color:#64748b; font-size:13px; line-height:1;
  width:26px; height:26px; display:inline-flex; align-items:center; justify-content:center;
  padding:0; transition: background .12s, color .12s, border-color .12s; }
.fb-move:hover:not(:disabled) { background:#f1f5f9; color:#0f172a; border-color:#cbd5e1; }
.fb-move:disabled { opacity:.35; cursor:not-allowed; }

.fb-delete { background:transparent; border:1px solid #fecaca; color:#991b1b;
  padding:3px 9px; border-radius:6px; cursor:pointer;
  font-size:11px; font-weight:600; transition: background .12s; }
.fb-delete:hover { background:#fef2f2; }

.fb-row { display:grid; grid-template-columns: 1fr 1fr auto; gap:8px; align-items:end; }
.fb-row .sc-field { gap:4px; }
.fb-row .sc-field label { font-size:10.5px; font-weight:600; color:#64748b; letter-spacing:.2px; }
.fb-row .sc-field input, .fb-row .sc-field textarea {
  padding: 7px 10px; font-size:12.5px; height:32px;
  border:1px solid #e2e8f0; border-radius:7px;
  background:#f8fafc; outline:none;
  transition: border-color .15s, background .15s, box-shadow .15s; }
.fb-row .sc-field input:focus, .fb-row .sc-field textarea:focus {
  background:white; border-color:#991b1b; box-shadow: 0 0 0 3px rgba(153,27,27,0.08); }
.fb-row .sc-field input:disabled { opacity:.5; }

.fb-required { display:inline-flex; align-items:center; gap:6px;
  height:32px; padding: 0 11px; border:1px solid #e2e8f0; border-radius:7px;
  background:white; cursor:pointer;
  font-size:12px; font-weight:600; color:#64748b;
  white-space:nowrap; user-select:none;
  transition: background .12s, color .12s, border-color .12s; }
.fb-required input { accent-color:#991b1b; width:13px; height:13px; margin:0; cursor:pointer; }
.fb-required input:disabled { cursor:not-allowed; }
.fb-required.on { background:#fef2f2; border-color:#fecaca; color:#991b1b; }

.fb-enable { display:inline-flex; align-items:center; gap:5px;
  height:26px; padding: 0 9px; border:1px solid #e2e8f0; border-radius:6px;
  background:white; cursor:pointer;
  font-size:11px; font-weight:600; color:#64748b;
  white-space:nowrap; user-select:none;
  transition: background .12s, color .12s, border-color .12s; }
.fb-enable input { accent-color:#16a34a; width:12px; height:12px; margin:0; cursor:pointer; }
.fb-enable.on { background:#dcfce7; border-color:#bbf7d0; color:#15803d; }
.fb-enable.off { background:#f1f5f9; border-color:#e2e8f0; color:#94a3b8; }

.fb-options { margin-top: 4px; }
.fb-options label { font-size:10.5px; font-weight:600; color:#64748b; display:block; margin-bottom:4px; letter-spacing:.2px; }
.fb-options textarea { width:100%; min-height:54px; padding:7px 10px;
  font:inherit; font-size:12.5px;
  border:1px solid #e2e8f0; border-radius:7px;
  background:#f8fafc; outline:none; resize:vertical; }
.fb-options textarea:focus { background:white; border-color:#991b1b;
  box-shadow: 0 0 0 3px rgba(153,27,27,0.08); }

.fb-add-row { margin-top: 8px; padding-top: 10px;
  border-top: 1px dashed #e2e8f0;
  display:flex; align-items:center; gap:5px; flex-wrap:wrap; }
.fb-add-row .muted { font-size:11.5px; margin-right:4px; }
.fb-add-btn { background:white; border:1px dashed #cbd5e1; color:#64748b;
  padding:5px 11px; border-radius:7px; cursor:pointer;
  font-size:11.5px; font-weight:500;
  transition: background .12s, color .12s, border-color .12s, border-style .12s; }
.fb-add-btn:hover { background:#fef2f2; border-color:#fecaca; color:#991b1b; border-style:solid; }

/* ============ DARK MODE ============ */
[data-theme="dark"] body { background:#09090b; color:#f1f5f9; }
[data-theme="dark"] #app-view { background:#09090b; }
[data-theme="dark"] .chat { background:#0c0c0e;
  background-image: radial-gradient(circle at 100% 0%, rgba(220,38,38,0.05) 0%, transparent 50%),
                    radial-gradient(circle at 0% 100%, rgba(37,99,235,0.03) 0%, transparent 50%); }
[data-theme="dark"] .empty h2 { color:#f1f5f9; }
[data-theme="dark"] .empty p { color:#71717a; }
[data-theme="dark"] .empty-ring { border-color: rgba(220,38,38,0.2); }
[data-theme="dark"] .chat-header { background:#18181b; border-bottom-color:#27272a; }
[data-theme="dark"] .chat-title-text h2 { color:#f1f5f9; }
[data-theme="dark"] .chat-status { color:#9ca3af; }
[data-theme="dark"] .chat-body { background: linear-gradient(180deg, #0c0c0e 0%, #131316 100%); }
[data-theme="dark"] .chat-body::-webkit-scrollbar-thumb { background:#2a2a2f; }
[data-theme="dark"] .msg.visitor { background:#27272a; color:#f1f5f9; border-color:#3f3f46; }
[data-theme="dark"] .msg.system { background:#1f1f23; color:#94a3b8; }
[data-theme="dark"] .typing { background:#27272a; border-color:#3f3f46; }
[data-theme="dark"] .typing span { background:#71717a; }
[data-theme="dark"] .chat-footer { background:#18181b; border-top-color:#27272a; }
[data-theme="dark"] .attach-preview { background:rgba(220,38,38,0.12); border-color:#7f1d1d; color:#fca5a5; }
[data-theme="dark"] .attach-preview button { color:#fca5a5; }
[data-theme="dark"] .msg-wrap textarea { background:#27272a; border-color:#3f3f46; color:#f1f5f9; }
[data-theme="dark"] .msg-wrap textarea:focus { background:#1f1f23;
  box-shadow: 0 0 0 3px rgba(220,38,38,0.18); border-color:#dc2626; }
[data-theme="dark"] .msg-wrap textarea::placeholder { color:#71717a; }
[data-theme="dark"] .input-hint { color:#71717a; }
[data-theme="dark"] .input-hint code { background:rgba(220,38,38,0.18); color:#fca5a5; }
[data-theme="dark"] .sc-popup { background:#18181b; border-color:#27272a; box-shadow: 0 16px 32px rgba(0,0,0,0.6); }
[data-theme="dark"] .sc-popup-item:hover, [data-theme="dark"] .sc-popup-item.active { background:#27272a; }
[data-theme="dark"] .sc-popup-title { color:#f1f5f9; }
[data-theme="dark"] .sc-popup-body { color:#9ca3af; }
[data-theme="dark"] .empty { color:#9ca3af; }
[data-theme="dark"] .empty h2 { color:#f1f5f9; }
[data-theme="dark"] .chat-header { box-shadow: 0 1px 0 rgba(0,0,0,0.3), 0 4px 12px -8px rgba(0,0,0,0.5); }
[data-theme="dark"] .chat-footer { box-shadow: 0 -4px 12px -8px rgba(0,0,0,0.5); }
[data-theme="dark"] .btn-ghost { background:#18181b; border-color:#27272a; color:#cbd5e1; }
[data-theme="dark"] .btn-ghost:hover { background:rgba(220,38,38,0.15); border-color:#7f1d1d; color:#fca5a5;
  box-shadow: 0 2px 8px rgba(220,38,38,0.15); }
[data-theme="dark"] .btn-secondary { background:#18181b; border-color:#27272a; color:#cbd5e1; }
[data-theme="dark"] .btn-secondary:hover { background:rgba(220,38,38,0.15); border-color:#7f1d1d; color:#fca5a5; }
[data-theme="dark"] .info-panel { background:#0c0c0e; border-left-color:#27272a; color:#f1f5f9; }
[data-theme="dark"] .info-panel::-webkit-scrollbar-thumb { background:#2a2a2f; }
[data-theme="dark"] .info-empty { color:#71717a; }
[data-theme="dark"] .info-section { background:#18181b; border-color:#27272a; box-shadow: 0 1px 2px rgba(0,0,0,0.4); }
[data-theme="dark"] .info-title::after { background:#27272a; }
[data-theme="dark"] .info-name { color:#f1f5f9; }
[data-theme="dark"] .info-email { color:#9ca3af; }
[data-theme="dark"] .info-email a { color:#fca5a5; }
[data-theme="dark"] .info-title { color:#71717a; }
[data-theme="dark"] .info-row + .info-row { border-top-color:#27272a; }
[data-theme="dark"] .info-label { color:#9ca3af; }
[data-theme="dark"] .info-value { color:#f1f5f9; }
[data-theme="dark"] .info-value.link, [data-theme="dark"] .info-value.link a { color:#fca5a5; }
[data-theme="dark"] #info-notes { background:#27272a; color:#f1f5f9; border-color:#3f3f46; }
[data-theme="dark"] #info-notes:focus { background:#1f1f23; box-shadow: 0 0 0 3px rgba(220,38,38,0.18); border-color:#dc2626; }
[data-theme="dark"] .info-pill.open { background:rgba(34,197,94,0.18); color:#86efac; }
[data-theme="dark"] .info-pill.closed { background:#27272a; color:#cbd5e1; }
[data-theme="dark"] .info-pill.archived { background:rgba(234,179,8,0.18); color:#fde68a; }
[data-theme="dark"] .info-pill.assigned { background:rgba(220,38,38,0.18); color:#fca5a5; }
[data-theme="dark"] .extra-row { background:#27272a; border-color:#3f3f46; }
[data-theme="dark"] .extra-label { color:#9ca3af; }
[data-theme="dark"] .extra-value { color:#f1f5f9; }
[data-theme="dark"] .notes-status { color:#71717a; }
[data-theme="dark"] .notes-status.saved { color:#22c55e; }
[data-theme="dark"] .modal-backdrop { background:rgba(0,0,0,0.7); }
[data-theme="dark"] .modal-card { background:#18181b; color:#f1f5f9;
  box-shadow:0 24px 64px rgba(0,0,0,0.7); border-top-color:#dc2626; }
[data-theme="dark"] .modal-head h2 { color:#f1f5f9; }
[data-theme="dark"] .modal .muted { color:#9ca3af; }
[data-theme="dark"] .modal-head .icon-btn { color:#cbd5e1; }
[data-theme="dark"] .modal-head .icon-btn:hover { background:rgba(220,38,38,0.18); color:#fca5a5; }
[data-theme="dark"] code { background:rgba(220,38,38,0.18); color:#fca5a5; }
[data-theme="dark"] kbd { background:#27272a; border-color:#3f3f46; color:#f1f5f9; }
[data-theme="dark"] .sc-form input, [data-theme="dark"] .sc-form textarea, [data-theme="dark"] .sc-form select {
  background:#27272a; border-color:#3f3f46; color:#f1f5f9; }
[data-theme="dark"] .sc-form input:focus, [data-theme="dark"] .sc-form textarea:focus, [data-theme="dark"] .sc-form select:focus {
  background:#1f1f23; box-shadow: 0 0 0 3px rgba(220,38,38,0.18); border-color:#dc2626; }
[data-theme="dark"] .sc-form input::placeholder, [data-theme="dark"] .sc-form textarea::placeholder { color:#71717a; }
[data-theme="dark"] .sc-list { background:#0c0c0e; border-color:#27272a; }
[data-theme="dark"] .sc-item { background:#18181b; border-bottom-color:#27272a; }
[data-theme="dark"] .sc-item .sc-title-line { color:#f1f5f9; }
[data-theme="dark"] .sc-item .sc-body-line { color:#9ca3af; }
[data-theme="dark"] .sc-item .sc-code { background:rgba(220,38,38,0.18); color:#fca5a5; }
[data-theme="dark"] .sc-item-actions button { color:#9ca3af; }
[data-theme="dark"] .sc-item-actions button:hover { background:#27272a; color:#f1f5f9; }
[data-theme="dark"] .sc-empty { color:#71717a; }

[data-theme="dark"] .fb-section { border-top-color:#27272a; }
[data-theme="dark"] .fb-section-title { color:#9ca3af; }
[data-theme="dark"] .fb-section p.muted.small { color:#9ca3af; }
[data-theme="dark"] .fb-section .sc-field input, [data-theme="dark"] .fb-section .sc-field textarea,
[data-theme="dark"] .fb-row .sc-field input, [data-theme="dark"] .fb-row .sc-field textarea {
  background:#1f1f23; border-color:#3a3a3f; color:#f1f5f9; }
[data-theme="dark"] .fb-section .sc-field input:focus, [data-theme="dark"] .fb-section .sc-field textarea:focus,
[data-theme="dark"] .fb-row .sc-field input:focus, [data-theme="dark"] .fb-row .sc-field textarea:focus {
  background:#27272a; border-color:#dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,0.18); }
[data-theme="dark"] .fb-section .sc-field input::placeholder,
[data-theme="dark"] .fb-row .sc-field input::placeholder { color:#52525b; }
[data-theme="dark"] .fb-section .sc-field label, [data-theme="dark"] .fb-row .sc-field label,
[data-theme="dark"] .sc-row .sc-field label { color:#9ca3af; }
[data-theme="dark"] .fb-field-card { background:#18181b; border-color:#27272a; }
[data-theme="dark"] .fb-field-card:hover { border-color:#3f3f46; box-shadow: 0 1px 6px rgba(0,0,0,0.3); }
[data-theme="dark"] .fb-field-card.system { background:#1c1611; border-color:#3d2a14; }
[data-theme="dark"] .fb-type-pill { background:#27272a; color:#cbd5e1; }
[data-theme="dark"] .fb-type-pill.system { background:#3d2a14; color:#fdba74; }
[data-theme="dark"] .fb-key { color:#71717a; }
[data-theme="dark"] .fb-required { background:#1f1f23; border-color:#3a3a3f; color:#cbd5e1; }
[data-theme="dark"] .fb-required.on { background: rgba(220,38,38,0.20); border-color: rgba(220,38,38,0.55); color:#fca5a5; }
[data-theme="dark"] .fb-enable { background:#1f1f23; border-color:#3a3a3f; color:#cbd5e1; }
[data-theme="dark"] .fb-enable.on { background: rgba(34,197,94,0.18); border-color: rgba(34,197,94,0.45); color:#86efac; }
[data-theme="dark"] .fb-enable.off { background:#1f1f23; border-color:#3a3a3f; color:#71717a; }
[data-theme="dark"] .fb-move { background:#1f1f23; border-color:#3a3a3f; color:#cbd5e1; }
[data-theme="dark"] .fb-move:hover:not(:disabled) { background:#27272a; color:#f1f5f9; border-color:#52525b; }
[data-theme="dark"] .fb-delete { background:transparent; border-color: rgba(220,38,38,0.4); color:#fca5a5; }
[data-theme="dark"] .fb-delete:hover { background: rgba(220,38,38,0.18); }
[data-theme="dark"] .fb-add-row { border-top-color:#27272a; }
[data-theme="dark"] .fb-add-row .muted { color:#9ca3af; }
[data-theme="dark"] .fb-add-btn { background:transparent; border-color:#3a3a3f; color:#9ca3af; }
[data-theme="dark"] .fb-add-btn:hover { background:rgba(220,38,38,0.18); border-color: rgba(220,38,38,0.5); color:#fca5a5; }
[data-theme="dark"] .fb-options label { color:#9ca3af; }
[data-theme="dark"] .fb-options textarea { background:#1f1f23; border-color:#3a3a3f; color:#f1f5f9; }
[data-theme="dark"] .fb-options textarea:focus { background:#27272a; border-color:#dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,0.18); }

[data-theme="dark"] .ban-card { background:#18181b; border-color:#27272a; }
[data-theme="dark"] .ban-val-code { background:#27272a; color:#f1f5f9; }
[data-theme="dark"] .ban-card-foot { border-top-color:#27272a; }
[data-theme="dark"] .ban-card-meta { color:#9ca3af; }
[data-theme="dark"] .ban-card-remove { background:transparent; border-color:#7f1d1d; color:#fca5a5; }
[data-theme="dark"] .ban-card-remove:hover { background:rgba(220,38,38,0.18); }
[data-theme="dark"] .ban-type-pill.ip { background:rgba(234,179,8,0.18); color:#fde68a; }
[data-theme="dark"] .ban-type-pill.visitor_id { background:rgba(37,99,235,0.18); color:#93c5fd; }
[data-theme="dark"] .ban-type-pill.email { background:rgba(190,24,93,0.22); color:#f9a8d4; }
[data-theme="dark"] .ban-summary { background:rgba(220,38,38,0.15); border-color:#7f1d1d; color:#fca5a5; }
[data-theme="dark"] .ban-summary .ban-label { color:#fca5a5; }
[data-theme="dark"] .conv-list::-webkit-scrollbar-thumb { background:#3f3f46; }
[data-theme="dark"] #theme-btn { color:#fde68a; }

/* ============ Confirm modal ============ */
.confirm-card { max-width: 400px !important; padding: 28px 26px 22px !important; text-align:center; }
.confirm-icon { font-size:44px; margin-bottom:8px; line-height:1; filter: drop-shadow(0 4px 12px rgba(153,27,27,0.25)); }
.confirm-card h2 { margin: 0 0 8px !important; font-size:18px !important; color:#0f172a; letter-spacing:-.2px; }
.confirm-card p { margin: 0 0 20px; color:#64748b; font-size:14px; line-height:1.55; }
.confirm-actions { display:flex; gap:10px; justify-content:center; }
.confirm-actions button { flex:1; max-width:150px; padding:10px 16px !important; font-size:13.5px !important; }
[data-theme="dark"] .confirm-card h2 { color:#f1f5f9; }
[data-theme="dark"] .confirm-card p { color:#9ca3af; }

/* ============ Details toggle ============ */
#app-view.info-hidden { grid-template-columns: 60px 280px 1fr; }
#app-view.info-hidden .info-panel { display: none; }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  #app-view, #app-view.info-hidden { grid-template-columns: 60px 260px 1fr; }
  .info-panel { display:none; }
  .info-panel.show { display:block; position:fixed; top:0; right:0; bottom:0; width:300px;
    z-index:200; box-shadow:-10px 0 30px rgba(0,0,0,0.15); }
}
@media (max-width: 700px) {
  #app-view, #app-view.info-hidden { grid-template-columns: 56px 220px 1fr; }
  .msg { max-width: 85%; }
  .sc-row { flex-direction:column; }
  .confirm-card { max-width: calc(100vw - 32px) !important; }
}
