/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:      #0a0a0f;
  --bg2:     #0f0f1a;
  --bg3:     #141428;
  --bg4:     #1a1a38;
  --blue:    #0088cc;
  --cyan:    #00d4ff;
  --cyan2:   #00aadd;
  --green:   #00e676;
  --orange:  #ff9100;
  --red:     #ff5252;
  --purple:  #7c4dff;
  --white:   #e8eaf6;
  --light:   #9fa8da;
  --muted:   #5c6bc0;
  --border:  rgba(0,212,255,0.12);
  --brand:   var(--config-brand-color, #00d4ff);
  --sidebar-w: 240px;
}
html, body { height: 100%; font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--white); font-size: 14px; line-height: 1.5; }
a { color: var(--cyan); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
[hidden] { display: none !important; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 3px; }

/* ===== TOASTS ===== */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 8px; font-size: 13px; font-weight: 500; max-width: 320px; animation: slideIn .25s ease; box-shadow: 0 4px 20px rgba(0,0,0,.4); }
.toast.success { background: #00e67620; border: 1px solid #00e67640; color: var(--green); }
.toast.error   { background: #ff525220; border: 1px solid #ff525240; color: var(--red); }
.toast.info    { background: #00d4ff15; border: 1px solid var(--border); color: var(--cyan); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ===== LOGIN ===== */
#view-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(ellipse at 50% 0%, rgba(0,212,255,.06) 0%, transparent 70%); }
.login-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 100%; max-width: 380px; box-shadow: 0 0 40px rgba(0,212,255,.08); }
.login-card .brand-logo { text-align: center; margin-bottom: 8px; }
.login-card .brand-logo img { max-height: 52px; max-width: 180px; object-fit: contain; }
.login-card h1 { text-align: center; font-family: 'Poppins', sans-serif; font-size: 22px; color: var(--brand); margin-bottom: 28px; }
.login-card .field { margin-bottom: 14px; }
.login-card label { display: block; font-size: 12px; color: var(--light); margin-bottom: 5px; }
.login-card input { width: 100%; padding: 10px 14px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--white); font-size: 14px; outline: none; transition: border-color .2s; }
.login-card input:focus { border-color: var(--brand); }
.login-card .btn-login { width: 100%; padding: 12px; background: var(--brand); color: #000; font-weight: 600; font-size: 15px; border: none; border-radius: 8px; margin-top: 8px; transition: opacity .2s, transform .1s; }
.login-card .btn-login:hover { opacity: .9; }
.login-card .btn-login:active { transform: scale(.98); }
#login-error { color: var(--red); font-size: 12px; text-align: center; margin-top: 10px; min-height: 18px; }

/* ===== APP SHELL ===== */
#app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
#sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w); height: 100vh; background: var(--bg2);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  transition: transform .3s; z-index: 100;
  overflow-y: auto;
}
#sidebar .brand { padding: 20px 16px 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
#sidebar .brand img { max-height: 32px; max-width: 100px; object-fit: contain; }
#sidebar .brand span { font-family: 'Poppins', sans-serif; font-size: 16px; font-weight: 600; color: var(--brand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sidebar nav ul { list-style: none; padding: 10px 8px; flex: 1; }
#sidebar nav ul li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 8px; cursor: pointer; color: var(--light); font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s; margin-bottom: 2px; position: relative;
}
#sidebar nav ul li:hover { background: var(--bg3); color: var(--white); }
#sidebar nav ul li.active { background: rgba(0,212,255,.1); color: var(--brand); }
#sidebar nav ul li .badge { margin-left: auto; background: var(--orange); color: #000; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 20px; min-width: 18px; text-align: center; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.sidebar-footer .user-info { display: flex; flex-direction: column; gap: 2px; }
.sidebar-footer .user-name { font-weight: 600; font-size: 13px; color: var(--white); }
.sidebar-footer .user-role { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.sidebar-footer .btn-logout { margin-top: 8px; width: 100%; padding: 7px; background: transparent; border: 1px solid var(--border); color: var(--light); border-radius: 6px; font-size: 12px; transition: background .15s; }
.sidebar-footer .btn-logout:hover { background: var(--bg3); color: var(--white); }

/* ===== MOBILE TOGGLE ===== */
#menu-toggle { display: none; position: fixed; top: 12px; left: 12px; z-index: 200; background: var(--bg3); border: 1px solid var(--border); color: var(--white); padding: 8px 11px; border-radius: 8px; font-size: 18px; }
#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 99; }

/* ===== SIDEBAR TRANSITION ===== */
#sidebar { transition: width .25s, min-width .25s, transform .3s; }

/* ===== SIDEBAR TOGGLE (desktop collapse) ===== */
#sidebar-toggle { background: transparent; border: 1px solid var(--border); color: var(--brand); font-size: 16px; padding: 5px 9px; border-radius: 6px; cursor: pointer; transition: color .15s, background .15s; margin-left: auto; }
#sidebar-toggle:hover { background: rgba(0,212,255,.1); }
#sidebar.collapsed #sidebar-toggle { margin-left: 0; }

/* ===== DESKTOP COLLAPSE ===== */
#sidebar.collapsed { width: 62px; min-width: 62px; }
#sidebar.collapsed .brand span,
#sidebar.collapsed nav ul li .label-text,
#sidebar.collapsed nav ul li .badge,
#sidebar.collapsed .user-info .user-name,
#sidebar.collapsed .user-info .user-role,
#sidebar.collapsed .btn-logout { display: none; }
#sidebar.collapsed nav ul li { justify-content: center; padding: 10px 8px; font-size: 18px; gap: 0; }
#sidebar.collapsed .brand { justify-content: center; padding: 18px 10px; }
#sidebar.collapsed .brand img { max-width: 32px; }
#sidebar.collapsed .sidebar-footer { padding: 8px; text-align: center; }
#sidebar.collapsed .sidebar-footer::before { content: '👤'; font-size: 18px; color: var(--brand); }

/* ===== MAIN ===== */
#main { flex: 1; height: 100%; min-height: 0; overflow-y: auto; overflow-x: hidden; background: var(--bg); }
.view { display: none; padding: 24px; }
.view.active { display: block; }
.view-flush { padding: 0 !important; height: 100%; overflow: hidden; }
.view-flush.active { display: flex; flex-direction: column; }

/* ===== PAGE HEADER ===== */
.page-header { margin-bottom: 20px; }
.page-header h2 { font-family: 'Poppins', sans-serif; font-size: 20px; font-weight: 600; color: var(--white); }
.page-header p { color: var(--light); font-size: 13px; margin-top: 2px; }

/* ===== KPI STRIP ===== */
.kpi-strip { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.kpi-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; flex: 1; min-width: 130px; transition: border-color .2s; }
.kpi-card:hover { border-color: var(--brand); }
.kpi-card .kpi-value { font-family: 'Poppins', sans-serif; font-size: 22px; font-weight: 700; color: var(--white); }
.kpi-card .kpi-label { font-size: 11px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }
.kpi-card.kpi-orange .kpi-value { color: var(--orange); }
.kpi-card.kpi-green .kpi-value  { color: var(--green); }
.kpi-card.kpi-cyan .kpi-value   { color: var(--cyan); }
.kpi-card.kpi-red .kpi-value    { color: var(--red); }

/* ===== FILTER BAR ===== */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-bar input, .filter-bar select {
  padding: 8px 12px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--white); font-size: 13px; outline: none; transition: border-color .2s;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--brand); }
.filter-bar input { flex: 1; min-width: 180px; }
.filter-bar select { min-width: 130px; }
.filter-bar .btn-filter { padding: 8px 16px; background: var(--brand); color: #000; border: none; border-radius: 8px; font-weight: 600; font-size: 13px; transition: opacity .2s; }
.filter-bar .btn-filter:hover { opacity: .85; }
.filter-bar .btn-clear { padding: 8px 12px; background: transparent; border: 1px solid var(--border); color: var(--light); border-radius: 8px; font-size: 13px; transition: background .15s; }
.filter-bar .btn-clear:hover { background: var(--bg3); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
table thead th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; background: var(--bg2); border-bottom: 1px solid var(--border); white-space: nowrap; }
table tbody tr { border-bottom: 1px solid rgba(255,255,255,.04); transition: background .1s; cursor: pointer; }
table tbody tr:last-child { border-bottom: none; }
table tbody tr:hover { background: var(--bg3); }
table tbody td { padding: 11px 14px; font-size: 13px; color: var(--white); vertical-align: middle; }
table tbody td.muted { color: var(--light); font-size: 12px; }

/* ===== STATE BADGES ===== */
.badge-state { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-state.handoff { background: rgba(255,145,0,.15); color: var(--orange); border: 1px solid rgba(255,145,0,.3); animation: pulseOrange 2s infinite; }
@keyframes pulseOrange { 0%,100% { box-shadow: 0 0 0 0 rgba(255,145,0,.3); } 50% { box-shadow: 0 0 0 4px rgba(255,145,0,.0); } }
.badge-state.active  { background: rgba(0,136,204,.15); color: var(--blue); border: 1px solid rgba(0,136,204,.3); }
.badge-state.won     { background: rgba(0,230,118,.12); color: var(--green); border: 1px solid rgba(0,230,118,.25); }
.badge-state.lost    { background: rgba(255,82,82,.1); color: var(--red); border: 1px solid rgba(255,82,82,.2); }
.badge-state.closed  { background: rgba(100,100,120,.15); color: #888; border: 1px solid rgba(100,100,120,.2); }

/* ===== LABEL CHIPS ===== */
.labels-wrap { display: flex; flex-wrap: wrap; gap: 4px; }
.label-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 10px; font-weight: 600; }
.label-chip .chip-remove { background: none; border: none; color: inherit; opacity: .6; font-size: 12px; padding: 0; margin-left: 2px; line-height: 1; cursor: pointer; }
.label-chip .chip-remove:hover { opacity: 1; }

/* ===== ACTION BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; border: none; transition: opacity .2s, background .15s; cursor: pointer; }
.btn:hover { opacity: .85; }
.btn:active { transform: scale(.98); }
.btn-primary   { background: var(--brand); color: #000; font-weight: 600; }
.btn-secondary { background: var(--bg3); color: var(--white); border: 1px solid var(--border); }
.btn-danger    { background: rgba(255,82,82,.15); color: var(--red); border: 1px solid rgba(255,82,82,.3); }
.btn-warning   { background: rgba(255,145,0,.15); color: var(--orange); border: 1px solid rgba(255,145,0,.3); }
.btn-success   { background: rgba(0,230,118,.12); color: var(--green); border: 1px solid rgba(0,230,118,.25); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; background: var(--bg3); border: 1px solid var(--border); color: var(--light); border-radius: 6px; font-size: 14px; transition: background .15s, color .15s; }
.btn-icon:hover { background: var(--bg4); color: var(--white); }

/* ===== INLINE ROW ACTIONS ===== */
.row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
tr:hover .row-actions { opacity: 1; }

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 16px; justify-content: center; }
.pagination span { color: var(--muted); font-size: 13px; }
.pagination button { padding: 6px 14px; background: var(--bg2); border: 1px solid var(--border); color: var(--white); border-radius: 7px; font-size: 13px; transition: background .15s; }
.pagination button:hover:not(:disabled) { background: var(--bg3); }
.pagination button:disabled { opacity: .4; cursor: default; }

/* ===== FOLLOW-UP ===== */
.followup-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 20px; }
.followup-badge.overdue { background: rgba(255,82,82,.12); color: var(--red); }
.followup-badge.upcoming { background: rgba(0,212,255,.1); color: var(--cyan); }

/* ===== DETAIL VIEW ===== */
#view-detail .detail-back { display: flex; align-items: center; gap: 8px; color: var(--light); font-size: 13px; margin-bottom: 16px; cursor: pointer; transition: color .15s; }
#view-detail .detail-back:hover { color: var(--brand); }
.detail-wrap { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.detail-panel { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.detail-panel-header { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; gap: 6px; }
.detail-panel-body { padding: 16px; }
.info-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.04); gap: 8px; }
.info-row:last-child { border-bottom: none; }
.info-key { font-size: 12px; color: var(--muted); min-width: 90px; }
.info-val { font-size: 13px; color: var(--white); text-align: right; word-break: break-word; max-width: 200px; }
.section-sep { margin: 14px 0 10px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; }
.section-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.form-field { margin-bottom: 12px; }
.form-field label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 5px; font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 8px 12px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--white); font-size: 13px; outline: none; transition: border-color .2s; resize: vertical;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--brand); }
.form-field input[type="color"] { padding: 4px 8px; height: 34px; cursor: pointer; }

/* ===== CHAT ===== */
.chat-outer { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; height: 600px; }
.chat-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.chat-header .chat-title { font-size: 13px; font-weight: 600; color: var(--white); }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-bubble { display: flex; flex-direction: column; max-width: 75%; }
.chat-bubble.user { align-items: flex-start; }
.chat-bubble.assistant { align-items: flex-end; align-self: flex-end; }
.chat-bubble .bubble { padding: 9px 13px; border-radius: 12px; font-size: 13px; line-height: 1.5; word-break: break-word; }
.chat-bubble.user .bubble { background: var(--bg3); color: var(--white); border-bottom-left-radius: 4px; }
.chat-bubble.assistant .bubble { background: rgba(0,212,255,.12); color: var(--white); border: 1px solid rgba(0,212,255,.2); border-bottom-right-radius: 4px; }
.chat-bubble .bubble-role { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.chat-bubble .bubble-time { font-size: 10px; color: var(--muted); margin-top: 3px; }
.chat-divider { text-align: center; color: var(--orange); font-size: 11px; font-weight: 600; margin: 8px 0; padding: 4px 12px; background: rgba(255,145,0,.08); border-radius: 20px; align-self: center; }
.chat-input-area { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-end; }
.chat-input-area textarea { flex: 1; padding: 9px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--white); font-size: 13px; outline: none; transition: border-color .2s; resize: none; max-height: 100px; min-height: 38px; }
.chat-input-area textarea:focus { border-color: var(--brand); }
.chat-input-area button { padding: 9px 16px; background: var(--brand); color: #000; border: none; border-radius: 8px; font-weight: 600; font-size: 13px; white-space: nowrap; }

/* ===== NOTES ===== */
.note-item { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.note-item .note-text { font-size: 13px; color: var(--white); line-height: 1.5; }
.note-item .note-meta { font-size: 11px; color: var(--muted); margin-top: 5px; }

/* ===== TIMELINE ===== */
.timeline-list { display: flex; flex-direction: column; gap: 10px; }
.timeline-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; background: var(--bg3); border-radius: 7px; border-left: 2px solid var(--brand); }
.timeline-icon { font-size: 16px; line-height: 1; margin-top: 2px; flex-shrink: 0; }
.timeline-content { flex: 1; min-width: 0; }
.timeline-title { font-size: 13px; color: var(--white); margin-bottom: 3px; }
.timeline-time { font-size: 11px; color: var(--muted); }

/* ===== TEMPLATE PICKER ===== */
.tpl-picker { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); width: 440px; max-width: 90vw; max-height: 400px; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.5); z-index: 500; display: flex; flex-direction: column; overflow: hidden; }
.tpl-picker-header { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--white); }
.tpl-picker-list { overflow-y: auto; max-height: 340px; }
.tpl-picker-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.04); transition: background .1s; }
.tpl-picker-item:hover { background: var(--bg3); }
.tpl-picker-item .tpl-shortcut { display: inline-block; background: rgba(0,212,255,.12); color: var(--brand); padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; margin-right: 8px; }
.tpl-picker-item .tpl-title { font-size: 12px; color: var(--white); }
.tpl-picker-item .tpl-content-preview { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== CHAT BUBBLE FLASH ===== */
.chat-bubble.bubble-new .bubble { animation: flashCyan 1.2s ease; }
@keyframes flashCyan { 0% { box-shadow: 0 0 0 0 rgba(0,212,255,.6); } 100% { box-shadow: 0 0 0 8px rgba(0,212,255,0); } }

/* ===== DASHBOARD ===== */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }
.dash-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.dash-card h3 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 14px; }
.service-bar { margin-bottom: 12px; }
.service-bar .sb-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--light); margin-bottom: 5px; }
.service-bar .sb-track { height: 7px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.service-bar .sb-fill { height: 100%; border-radius: 4px; background: var(--brand); transition: width .5s ease; }

/* ===== REPORTS ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab-btn { padding: 10px 16px; background: transparent; border: none; color: var(--muted); font-size: 13px; font-weight: 500; border-bottom: 2px solid transparent; cursor: pointer; transition: color .15s, border-color .15s; margin-bottom: -1px; }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.funnel-row { display: flex; align-items: center; margin-bottom: 14px; gap: 12px; }
.funnel-row .f-label { min-width: 180px; font-size: 13px; color: var(--light); }
.funnel-row .f-track { flex: 1; height: 24px; background: var(--bg3); border-radius: 4px; overflow: hidden; position: relative; }
.funnel-row .f-fill { height: 100%; border-radius: 4px; display: flex; align-items: center; padding-left: 8px; font-size: 11px; font-weight: 700; color: #000; transition: width .6s ease; }
.funnel-row .f-num { min-width: 40px; text-align: right; font-size: 13px; font-weight: 600; color: var(--white); }
.timeline-row { display: flex; align-items: flex-end; gap: 4px; height: 100px; margin: 16px 0; }
.tl-bar { flex: 1; min-width: 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; justify-content: flex-end; }
.tl-bar .tl-fill { width: 100%; border-radius: 3px 3px 0 0; transition: height .4s ease; min-height: 2px; background: var(--brand); }
.tl-bar .tl-won { background: var(--green); }
.tl-bar .tl-date { font-size: 9px; color: var(--muted); white-space: nowrap; overflow: hidden; width: 100%; text-align: center; }
.stat-big { font-family: 'Poppins', sans-serif; font-size: 48px; font-weight: 700; color: var(--cyan); }
.stat-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ===== USERS ===== */
.user-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; display: flex; align-items: center; gap: 14px; }
.user-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--bg4); border: 2px solid var(--border); object-fit: cover; display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--muted); flex-shrink: 0; }
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-bottom: 24px; }

/* ===== SETTINGS ===== */
.settings-section { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 24px; margin-bottom: 20px; }
.settings-section h3 { font-size: 15px; font-weight: 600; color: var(--white); margin-bottom: 6px; }
.settings-section .section-desc { color: var(--muted); font-size: 12px; margin-bottom: 18px; }
.schedule-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.schedule-row .day-label { min-width: 80px; font-size: 13px; color: var(--light); }
.schedule-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.schedule-row .time-inputs { display: flex; align-items: center; gap: 6px; flex: 1; }
.schedule-row input[type="time"] { padding: 5px 8px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--white); font-size: 12px; outline: none; }
.labels-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.label-list-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg3); border-radius: 8px; }
.label-list-item .lbl-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.label-list-item .lbl-name { flex: 1; font-size: 13px; color: var(--white); }
.label-list-item .lbl-actions { display: flex; gap: 6px; }
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row .color-preview { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border); }
.warning-box { background: rgba(255,145,0,.08); border: 1px solid rgba(255,145,0,.2); border-radius: 8px; padding: 10px 14px; color: var(--orange); font-size: 12px; margin-bottom: 14px; }

/* ===== LOADING ===== */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--muted); }
.spinner { width: 24px; height: 24px; border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin-right: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== CHAT VIEW (4-col layout) ===== */
.chat-layout { display: grid; grid-template-columns: 320px 1fr 300px; height: 100%; flex: 1; min-height: 0; background: var(--bg); }

/* Col 2 — Lista de conversas */
.conv-col { background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.conv-header { padding: 16px 14px 10px; border-bottom: 1px solid var(--border); }
.conv-header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.conv-header-top h2 { font-family: 'Poppins', sans-serif; font-size: 17px; font-weight: 600; color: var(--white); }
.conv-header-top .conv-sound-toggle { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 5px 9px; border-radius: 6px; font-size: 13px; cursor: pointer; transition: color .15s, background .15s; }
.conv-header-top .conv-sound-toggle.active { color: var(--brand); border-color: var(--brand); }
.conv-filters { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.conv-filters select { flex: 1; padding: 6px 10px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--white); font-size: 12px; outline: none; transition: border-color .15s; }
.conv-filters select:focus { border-color: var(--brand); }
.conv-filters .icon-btn { padding: 6px 10px; background: var(--bg3); border: 1px solid var(--border); color: var(--light); border-radius: 6px; font-size: 13px; cursor: pointer; }
.conv-search-wrap { position: relative; }
.conv-search-wrap input { width: 100%; padding: 8px 12px 8px 32px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--white); font-size: 12px; outline: none; transition: border-color .15s; }
.conv-search-wrap input:focus { border-color: var(--brand); }
.conv-search-wrap::before { content: '🔍'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: .6; pointer-events: none; }

.conv-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 0; min-height: 0; }
.conv-item { display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; padding: 10px 14px; cursor: pointer; border-left: 3px solid transparent; transition: background .1s; align-items: center; }
.conv-item:hover { background: rgba(255,255,255,.025); }
.conv-item.selected { background: var(--bg3); border-left-color: var(--brand); }
.conv-avatar { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, var(--bg4) 0%, var(--bg3) 100%); border: 2px solid var(--border); color: var(--brand); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative; }
.conv-avatar.handoff::after { content: ''; position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; background: var(--orange); border: 2px solid var(--bg2); border-radius: 50%; animation: pulseOrange 2s infinite; }
.conv-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-name { font-size: 13.5px; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-preview { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; min-width: 42px; }
.conv-time { font-size: 10px; color: var(--muted); white-space: nowrap; }
.conv-icons { display: flex; gap: 4px; align-items: center; }
.conv-unread-badge { background: var(--brand); color: #000; font-size: 9px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 10px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; }
.conv-assigned-dot { font-size: 11px; color: var(--muted); }

/* Col 3 — Chat central */
.chat-col { display: flex; flex-direction: column; background: var(--bg); overflow: hidden; border-right: 1px solid var(--border); min-height: 0; }
.chat-col-header { padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--bg2); display: flex; align-items: center; gap: 12px; }
.chat-col-header .conv-avatar { width: 38px; height: 38px; font-size: 13px; }
.chat-col-header .chat-col-title { flex: 1; min-width: 0; }
.chat-col-header .chat-col-title .t1 { font-size: 14px; font-weight: 600; color: var(--white); }
.chat-col-header .chat-col-title .t2 { font-size: 11px; color: var(--muted); }
.chat-col-header .info-toggle { background: transparent; border: none; color: var(--muted); font-size: 22px; line-height: 1; padding: 6px 10px; border-radius: 6px; cursor: pointer; transition: color .15s, background .15s; flex-shrink: 0; }
.chat-col-header .info-toggle:hover { color: var(--brand); background: var(--bg3); }

.chat-col-messages { flex: 1 1 0; overflow-y: auto; overflow-x: hidden; padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); min-height: 0; }
.chat-col-messages::-webkit-scrollbar { width: 8px; }
.chat-col-messages::-webkit-scrollbar-track { background: transparent; }
.chat-col-messages::-webkit-scrollbar-thumb { background: rgba(0,212,255,.25); border-radius: 4px; }
.chat-col-messages::-webkit-scrollbar-thumb:hover { background: rgba(0,212,255,.5); }
.conv-list::-webkit-scrollbar { width: 8px; }
.conv-list::-webkit-scrollbar-thumb { background: rgba(0,212,255,.2); border-radius: 4px; }
.chat-col-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); padding: 40px 20px; text-align: center; }
.chat-col-empty .empty-icon { font-size: 64px; margin-bottom: 14px; opacity: .5; }
.chat-col-empty h3 { font-family: 'Poppins', sans-serif; font-size: 18px; color: var(--light); margin-bottom: 6px; }
.chat-col-empty p { font-size: 13px; max-width: 320px; }

.chat-col-input { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--bg2); display: flex; gap: 8px; align-items: flex-end; }
.chat-col-input .input-tools { display: flex; gap: 4px; }
.chat-col-input .input-tools button { background: transparent; border: none; color: var(--muted); font-size: 18px; padding: 6px 8px; border-radius: 6px; cursor: pointer; transition: color .15s, background .15s; }
.chat-col-input .input-tools button:hover { color: var(--brand); background: var(--bg3); }
.chat-col-input textarea { flex: 1; padding: 10px 14px; background: var(--bg3); border: 1px solid var(--border); border-radius: 20px; color: var(--white); font-size: 13.5px; outline: none; resize: none; min-height: 40px; max-height: 120px; transition: border-color .15s; font-family: inherit; }
.chat-col-input textarea:focus { border-color: var(--brand); }
.chat-col-input .btn-send { width: 42px; height: 42px; border-radius: 50%; background: var(--brand); color: #000; border: none; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: opacity .15s, transform .1s; flex-shrink: 0; }
.chat-col-input .btn-send:hover { opacity: .88; }
.chat-col-input .btn-send:active { transform: scale(.94); }
.chat-col-input .btn-send:disabled { opacity: .3; cursor: not-allowed; }

/* Col 4 — Painel de info do contato */
.info-col { background: var(--bg2); overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; min-height: 0; }
.info-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.info-header .info-name-wrap h3 { font-size: 15px; font-weight: 600; color: var(--white); display: flex; align-items: center; gap: 6px; }
.info-header .info-phone { font-size: 11px; color: var(--muted); margin-top: 2px; }
.info-header .info-actions { display: flex; gap: 4px; }
.info-header .info-actions button { background: transparent; border: 1px solid var(--border); color: var(--light); padding: 5px 9px; border-radius: 6px; font-size: 12px; cursor: pointer; transition: color .15s, border-color .15s; }
.info-header .info-actions button:hover { color: var(--brand); border-color: var(--brand); }

.info-avatar-big { width: 112px; height: 112px; border-radius: 50%; background: linear-gradient(135deg, var(--bg4) 0%, var(--bg3) 100%); border: 3px solid var(--border); color: var(--brand); font-weight: 700; font-size: 36px; display: flex; align-items: center; justify-content: center; margin: 20px auto 10px; }

.info-section { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.info-section:last-child { border-bottom: none; }
.info-section-title { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.info-status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.info-status-chip.open { background: rgba(0,230,118,.12); color: var(--green); border: 1px solid rgba(0,230,118,.25); }
.info-status-chip.closed { background: rgba(100,100,120,.15); color: #888; border: 1px solid rgba(100,100,120,.2); }
.info-row-slim { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12px; }
.info-row-slim .k { color: var(--muted); }
.info-row-slim .v { color: var(--white); text-align: right; word-break: break-word; max-width: 170px; }

/* Responsive */
@media (max-width: 1200px) {
  .chat-layout { grid-template-columns: 300px 1fr; }
  .info-col { position: fixed; right: 0; top: 0; width: 320px; height: 100vh; border-left: 1px solid var(--border); transform: translateX(100%); transition: transform .25s; z-index: 80; box-shadow: -4px 0 20px rgba(0,0,0,.4); }
  .info-col.open { transform: translateX(0); }
}
@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; }
  .conv-col { display: flex; }
  .chat-col { display: none; }
  .chat-layout.show-chat .conv-col { display: none; }
  .chat-layout.show-chat .chat-col { display: flex; }
}

/* ===== CONV STATE TABS ===== */
.conv-state-tabs { display: flex; gap: 4px; padding: 8px 14px 6px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.conv-state-tabs::-webkit-scrollbar { height: 2px; }
.cst-tab { background: transparent; border: 1px solid transparent; color: var(--muted); font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 20px; cursor: pointer; white-space: nowrap; transition: all .15s; }
.cst-tab:hover { color: var(--white); background: var(--bg3); }
.cst-tab.active { background: rgba(0,212,255,.12); color: var(--brand); border-color: rgba(0,212,255,.3); }

/* ===== CONV QUICK ACTIONS ===== */
.conv-item { position: relative; }
.conv-label-dots { display: flex; gap: 3px; align-items: center; }
.conv-label-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.conv-quick { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: none; flex-direction: column; gap: 3px; }
.conv-item:hover .conv-quick { display: flex; }
.conv-item:hover .conv-meta { visibility: hidden; }
.conv-quick button { background: var(--bg4); border: 1px solid var(--border); color: var(--white); padding: 4px 7px; border-radius: 5px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.conv-quick button:hover { background: var(--brand); color: #000; border-color: var(--brand); }

/* ===== WA STATUS ===== */
.wa-status-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.wa-status-dot.open { background: var(--green); box-shadow: 0 0 8px rgba(0,230,118,.5); }
.wa-status-dot.connecting { background: var(--orange); animation: pulseOrange 1.5s infinite; }
.wa-status-dot.close { background: var(--red); }

/* ===== BOT STATUS CHIP ===== */
.bot-status-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.bot-status-chip.bot-on { background: rgba(0,230,118,.1); color: var(--green); border: 1px solid rgba(0,230,118,.2); }
.bot-status-chip.bot-off { background: rgba(255,145,0,.1); color: var(--orange); border: 1px solid rgba(255,145,0,.2); }

/* ===== MOBILE BACK BUTTON ===== */
.chat-back-btn { display: none; background: transparent; border: none; color: var(--brand); font-size: 22px; padding: 4px 10px 4px 0; cursor: pointer; }
@media (max-width: 900px) { .chat-back-btn { display: block; } }

/* ===== COMING SOON PLACEHOLDER ===== */
.coming-soon { min-height: calc(100vh - 48px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 20px; }
.coming-soon .cs-icon { font-size: 80px; margin-bottom: 20px; opacity: .7; filter: drop-shadow(0 0 30px rgba(0,212,255,.3)); }
.coming-soon h2 { font-family: 'Poppins', sans-serif; font-size: 28px; color: var(--brand); margin-bottom: 12px; }
.coming-soon .cs-desc { color: var(--light); font-size: 14px; max-width: 500px; line-height: 1.7; margin-bottom: 20px; }
.coming-soon .cs-badge { background: rgba(0,212,255,.1); border: 1px solid rgba(0,212,255,.3); color: var(--brand); padding: 6px 16px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* ===== MODAL / CONFIRM ===== */
#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: 28px; max-width: 400px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-box h3 { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.modal-box p { color: var(--light); font-size: 13px; margin-bottom: 20px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #menu-toggle { display: block; }
  #sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #sidebar-overlay.open { display: block; }
  #main { width: 100%; }
  .view { padding: 16px; padding-top: 56px; }
  .detail-wrap { grid-template-columns: 1fr; }
  .chat-outer { height: 450px; }
  .kpi-strip { gap: 8px; }
  .kpi-card { min-width: 100px; padding: 12px; }
  .kpi-card .kpi-value { font-size: 18px; }
  .filter-bar { flex-direction: column; }
  .filter-bar input, .filter-bar select { width: 100%; }
  table td:nth-child(n+5) { display: none; }
}