/* ============================================================
   Hub Platform — Design System (OmniChat-inspired)
   Dark-first. Theme via [data-theme="light"] on <html>.
   ============================================================ */

/* ---------- THEME TOKENS ---------- */
:root,
:root[data-theme="dark"] {
  --bg: #0d0f12;
  --bg-alt: #15181d;
  --bg-panel: #1a1e24;
  --bg-hover: #22272e;
  --bg-input: #1e2228;
  --border: #2a3038;
  --border-light: #363d47;
  --text: #e8eaed;
  --text-mut: #9aa3ad;
  --text-dim: #6b7480;
  --accent: #5b8def;
  --accent-dim: #1e3a5f;
  --accent-soft: #16243a;
  --green: #3ecf8e;  --green-dim: #163a2a;
  --red: #f0616d;    --red-dim: #3a1a1e;
  --amber: #f5a623;  --amber-dim: #3a2c12;
  --purple: #a78bfa; --purple-dim: #2a2342;
  --teal: #2dd4bf;
  --pink: #f472b6;
  --orange: #fb923c;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.5);
  --msg-dots: rgba(255,255,255,.04);
}
:root[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-alt: #ffffff;
  --bg-panel: #ffffff;
  --bg-hover: #eef0f3;
  --bg-input: #f0f2f5;
  --border: #e2e5ea;
  --border-light: #d0d4da;
  --text: #1a1d21;
  --text-mut: #5f6671;
  --text-dim: #9aa0a8;
  --accent: #2563eb;
  --accent-dim: #dbeafe;
  --accent-soft: #eff6ff;
  --green: #16a34a;  --green-dim: #dcfce7;
  --red: #dc2626;    --red-dim: #fee2e2;
  --amber: #d97706;  --amber-dim: #fef3c7;
  --purple: #7c3aed; --purple-dim: #ede9fe;
  --teal: #0d9488;
  --pink: #db2777;
  --orange: #ea580c;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 8px 24px rgba(0,0,0,.12);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.18);
  --msg-dots: rgba(0,0,0,.04);
}

/* ---------- RESET / BASE ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
#app { height: 100vh; display: flex; overflow: hidden; }
input, textarea, select, button { font-family: inherit; color: inherit; }
input:focus, textarea:focus, select:focus { outline: none; }
textarea { resize: none; }
a { color: var(--accent); text-decoration: none; }
select option { background: var(--bg-panel); color: var(--text); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
.scrollbar-thin::-webkit-scrollbar { width: 6px; height: 6px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.spin { animation: spin 1s linear infinite; }

/* ============================================================
   RAIL (sidebar)
   ============================================================ */
.sidebar {
  width: 60px; background: var(--bg-alt); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 4px; flex-shrink: 0; z-index: 50;
}
.sidebar-logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 16px; margin-bottom: 10px;
}
.sidebar-nav { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sidebar-bottom { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.nav-btn {
  width: 42px; height: 42px; border-radius: 11px; border: none; cursor: pointer;
  background: transparent; color: var(--text-mut);
  display: flex; align-items: center; justify-content: center;
  position: relative; transition: background .12s, color .12s;
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); }
.nav-btn .badge {
  position: absolute; top: 5px; right: 5px;
  min-width: 16px; height: 16px; border-radius: 8px;
  background: var(--red); color: #fff; font-size: 9.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
/* tooltip */
.nav-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: 52px; top: 50%; transform: translateY(-50%);
  background: var(--bg-panel); color: var(--text); font-size: 12px; font-weight: 500;
  padding: 6px 10px; border-radius: 7px; white-space: nowrap;
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; transition: opacity .1s; z-index: 100;
}
.nav-btn[data-tip]:hover::after { opacity: 1; }
.avatar-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; cursor: pointer;
  margin-top: 6px; position: relative;
}
.avatar-btn::after {
  content: ""; position: absolute; bottom: -1px; right: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--green); border: 2px solid var(--bg-alt);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.main { flex: 1; display: flex; overflow: hidden; min-width: 0; }

/* ============================================================
   CONVERSATION LIST PANEL
   ============================================================ */
.conv-panel {
  width: 340px; background: var(--bg-alt); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.panel-header { padding: 16px 16px 12px; border-bottom: 1px solid var(--border); }
.panel-header .row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-header h2 { font-size: 17px; font-weight: 600; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 11px; margin-bottom: 12px;
}
.search-box input { flex: 1; background: transparent; border: none; font-size: 13.5px; }
.search-box svg { color: var(--text-dim); flex-shrink: 0; }

.filter-tabs { display: flex; gap: 4px; }
.filter-tab {
  flex: 1; padding: 7px 4px; border-radius: 7px; border: none; cursor: pointer;
  font-size: 12.5px; font-weight: 500; background: transparent; color: var(--text-mut);
  display: flex; align-items: center; justify-content: center; gap: 5px; transition: all .12s;
}
.filter-tab:hover { color: var(--text); }
.filter-tab.active { background: var(--accent-soft); color: var(--accent); }
.filter-tab .cnt {
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 8px;
  background: var(--border); color: var(--text-mut);
}
.filter-tab.active .cnt { background: var(--accent); color: #fff; }

.mini-filters { display: flex; gap: 6px; margin-top: 8px; }
.mini-select {
  flex: 1; min-width: 0; padding: 6px 8px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text-mut); font-size: 11.5px; cursor: pointer;
}

.conv-list { flex: 1; overflow-y: auto; padding: 6px 8px; }
.conv-item {
  display: flex; gap: 11px; padding: 11px 10px; border-radius: 10px; cursor: pointer;
  margin-bottom: 2px; border: 1px solid transparent; transition: all .1s;
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.conv-item .av-wrap { position: relative; flex-shrink: 0; }
.conv-item .info { flex: 1; min-width: 0; }
.conv-item .name-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.conv-item .name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item.unread .name { font-weight: 600; }
.conv-item .time { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.conv-item .preview-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 3px; }
.conv-item .preview { font-size: 12.5px; color: var(--text-mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-item.unread .preview { color: var(--text); font-weight: 500; }
.conv-item .meta-row { display: flex; align-items: center; gap: 5px; margin-top: 6px; flex-wrap: wrap; }

.avatar {
  border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; flex-shrink: 0;
}
.av-42 { width: 42px; height: 42px; font-size: 15px; }
.av-40 { width: 40px; height: 40px; font-size: 14px; }
.av-36 { width: 36px; height: 36px; font-size: 13px; }
.av-32 { width: 32px; height: 32px; font-size: 12px; }
.av-28 { width: 28px; height: 28px; font-size: 11px; }
.channel-dot {
  position: absolute; bottom: -2px; right: -2px;
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid var(--bg-alt);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
}

.unread-badge {
  min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  padding: 0 5px; flex-shrink: 0;
}
.channel-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 6px;
  background: var(--bg-hover); color: var(--text-mut);
}
.channel-whatsapp { background: rgba(37,211,102,.14); color: #25D366; }
.channel-instagram { background: rgba(225,48,108,.14); color: #E1306C; }
.channel-facebook { background: rgba(24,119,242,.14); color: #1877F2; }
.channel-telegram { background: rgba(0,136,204,.14); color: #2aa8e8; }
.channel-email { background: rgba(234,67,53,.14); color: #ea6a5f; }
.channel-api { background: var(--accent-soft); color: var(--accent); }
.channel-web { background: var(--accent-soft); color: var(--accent); }

/* ============================================================
   THREAD (chat panel)
   ============================================================ */
.thread { flex: 1; display: flex; flex-direction: column; background: var(--bg); min-width: 0; }
.thread-header {
  height: 64px; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--bg-alt);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 12px;
}
.thread-header .who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.thread-header .contact-name { font-weight: 500; font-size: 15px; }
.thread-header .contact-sub { font-size: 12.5px; color: var(--text-mut); margin-top: 2px; }
.thread-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.messages {
  flex: 1; overflow-y: auto; padding: 16px 24px;
  background-image: radial-gradient(var(--msg-dots) 1px, transparent 1px);
  background-size: 24px 24px;
}
.date-divider { display: flex; align-items: center; justify-content: center; margin: 16px 0; }
.date-divider span {
  font-size: 11.5px; color: var(--text-dim); background: var(--bg-alt);
  padding: 3px 12px; border-radius: 12px; border: 1px solid var(--border);
}
.msg-row { display: flex; margin-bottom: 8px; align-items: flex-end; gap: 8px; }
.msg-row.out { justify-content: flex-end; }
.msg-row.in { justify-content: flex-start; }
.msg-col { max-width: 64%; }
.msg-bubble {
  padding: 9px 13px; font-size: 14px; line-height: 1.5; word-break: break-word;
  white-space: pre-wrap; box-shadow: var(--shadow-sm);
}
.msg-row.in .msg-bubble { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; }
.msg-row.out .msg-bubble { background: var(--accent); color: #fff; border-radius: 14px 14px 4px 14px; }
.msg-foot { display: flex; align-items: center; gap: 4px; margin-top: 3px; padding: 0 4px; font-size: 10.5px; color: var(--text-dim); }
.msg-row.out .msg-foot { justify-content: flex-end; }
/* internal note */
.msg-row.note { justify-content: center; }
.note-bubble {
  max-width: 70%; background: var(--amber-dim); border: 1px solid color-mix(in srgb, var(--amber) 40%, transparent);
  border-radius: 10px; padding: 10px 13px;
}
.note-bubble .note-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 11.5px; font-weight: 600; color: var(--amber); }
.note-bubble p { font-size: 13.5px; line-height: 1.5; }

/* composer */
.thread-composer { border-top: 1px solid var(--border); background: var(--bg-alt); padding: 10px 16px 14px; flex-shrink: 0; position: relative; }
.composer-tabs { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.composer-tab {
  display: flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 7px;
  font-size: 12px; font-weight: 500; border: none; cursor: pointer;
  background: transparent; color: var(--text-mut);
}
.composer-tab.active { background: var(--accent-soft); color: var(--accent); }
.composer-tab.note.active { background: var(--amber-dim); color: var(--amber); }
.composer-hint { margin-left: auto; font-size: 11.5px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; }
.composer-box {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; padding: 8px 8px 8px 14px;
}
.composer-box.note { background: var(--amber-dim); border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.composer-input { flex: 1; background: transparent; border: none; font-size: 14px; line-height: 1.5; max-height: 120px; padding: 4px 0; }
.composer-actions { display: flex; align-items: center; gap: 2px; }
.btn-send {
  width: 38px; height: 38px; border-radius: 10px; border: none; cursor: pointer; margin-left: 4px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; transition: all .12s;
}
.btn-send:hover { filter: brightness(1.08); }
.btn-send:disabled { background: var(--border); opacity: .6; cursor: default; }
.btn-send.note { background: var(--amber); }

.canned-pop {
  position: absolute; bottom: 100%; left: 16px; right: 16px; margin-bottom: 8px;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px; padding: 6px;
  max-height: 260px; overflow-y: auto; box-shadow: var(--shadow-md); z-index: 30; animation: slideUp .12s;
}
.canned-pop .ch { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; color: var(--text-dim); padding: 6px 8px; text-transform: uppercase; letter-spacing: .4px; }
.canned-item { display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px; border: none; background: transparent; cursor: pointer; }
.canned-item:hover { background: var(--bg-hover); }
.canned-item .short { font-size: 11.5px; font-weight: 700; color: var(--accent); }
.canned-item .txt { display: block; font-size: 12.5px; color: var(--text-mut); margin-top: 3px; line-height: 1.4; }

/* no-selection placeholder */
.no-chat { flex: 1; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.no-chat .big-icon { width: 80px; height: 80px; border-radius: 20px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.no-chat h3 { color: var(--text); font-weight: 500; margin-top: 16px; }
.no-chat p { color: var(--text-mut); font-size: 14px; margin-top: 6px; }
.kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px;
  padding: 0 6px; border-radius: 5px; background: var(--bg-input); border: 1px solid var(--border);
  font-size: 11px; font-weight: 600; color: var(--text-mut); font-family: monospace;
}

/* ============================================================
   RIGHT / CONTACT PANEL
   ============================================================ */
.right-panel {
  width: 320px; background: var(--bg-alt); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto;
}
.rp-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.rp-section h3 { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; }
.rp-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.rp-label { font-size: 12px; color: var(--text-mut); }
.rp-value { font-size: 13px; font-weight: 500; text-align: right; }
.rp-profile { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.assignee-select, .rp-select {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-input); font-size: 13px; cursor: pointer;
}

/* ============================================================
   STATUS / PRIORITY / LABEL CHIPS
   ============================================================ */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 500; padding: 4px 10px; border-radius: 8px;
}
.status-open { background: var(--green-dim); color: var(--green); }
.status-resolved { background: var(--bg-hover); color: var(--text-mut); }
.status-pending { background: var(--amber-dim); color: var(--amber); }
.status-snoozed { background: var(--purple-dim); color: var(--purple); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.priority-low { background: var(--green); }
.priority-medium { background: var(--amber); }
.priority-high { background: var(--orange); }
.priority-urgent { background: var(--red); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 500; }
.tag-soft { background: var(--accent-soft); color: var(--accent); }

/* ============================================================
   GENERIC CONTENT AREA (full views)
   ============================================================ */
.content-area { flex: 1; display: flex; flex-direction: column; background: var(--bg); min-width: 0; overflow: hidden; }
.content-header {
  padding: 20px 28px; border-bottom: 1px solid var(--border); background: var(--bg-alt);
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.content-header h1 { font-size: 21px; font-weight: 600; }
.content-header .sub { font-size: 13.5px; color: var(--text-mut); margin-top: 3px; }
.content-header .spacer { flex: 1; }
.content-body { flex: 1; overflow-y: auto; padding: 20px 28px; }

.sub-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 28px; background: var(--bg-alt); flex-shrink: 0; }
.sub-tab { padding: 12px 14px; font-size: 13px; font-weight: 500; color: var(--text-mut); cursor: pointer; border-bottom: 2px solid transparent; transition: all .12s; }
.sub-tab:hover { color: var(--text); }
.sub-tab.active { color: var(--accent); border-color: var(--accent); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 9px;
  border: none; background: var(--accent); color: #fff; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: filter .12s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg-input); color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; transition: all .12s;
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--red) 45%, transparent); background: transparent; color: var(--red); font-size: 13px; font-weight: 500; cursor: pointer;
}
.btn-danger:hover { background: var(--red-dim); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn-ghost { background: transparent; border: none; color: var(--text-mut); cursor: pointer; padding: 7px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; transition: all .12s; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-ghost.active { background: var(--accent-soft); color: var(--accent); }
.btn-icon { background: transparent; border: 1px solid var(--border); cursor: pointer; padding: 7px; border-radius: 8px; color: var(--text-mut); display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }

/* ============================================================
   CARDS / TABLES
   ============================================================ */
.card { background: var(--bg-alt); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 8px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .3px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: var(--bg-hover); }
.cell-strong { font-weight: 500; }
.cell-mut { color: var(--text-mut); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-card { background: var(--bg-alt); border-radius: 12px; padding: 18px; border: 1px solid var(--border); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.kpi-trend { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.kpi-trend.up { color: var(--green); }
.kpi-trend.down { color: var(--red); }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 12px; }
.kpi-label { font-size: 12.5px; color: var(--text-mut); margin-top: 2px; }

/* legacy stat-card (used by Finance/Reports dashboards) */
.stat-card { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.stat-card .stat-label { font-size: 12.5px; color: var(--text-mut); }
.stat-card .stat-val { font-size: 26px; font-weight: 700; margin-top: 8px; }

/* report cards / charts */
.report-row { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.report-card { flex: 1; min-width: 280px; background: var(--bg-alt); border-radius: 12px; padding: 20px; border: 1px solid var(--border); }
.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 180px; margin-top: 24px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; }
.bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar { width: 70%; max-width: 44px; border-radius: 6px 6px 0 0; min-height: 4px; position: relative; transition: height .3s; background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 66%, transparent)); }
.bar-val { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 600; color: var(--text-mut); }
.bar-label { font-size: 11.5px; color: var(--text-mut); }
.progress-track { height: 7px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .4s; }
.mini-track { width: 60px; height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden; display: inline-block; }
.mini-fill { height: 100%; border-radius: 3px; display: block; }

/* ============================================================
   KANBAN
   ============================================================ */
.kanban-board { display: flex; gap: 14px; height: 100%; overflow-x: auto; align-items: flex-start; padding-bottom: 8px; }
.kanban-col { min-width: 272px; width: 272px; background: var(--bg-alt); border-radius: 12px; border: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; max-height: 100%; }
.kanban-col.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.kanban-col-header { padding: 14px 14px 6px; display: flex; align-items: center; gap: 7px; }
.kanban-col-title { font-size: 13.5px; font-weight: 500; }
.kanban-count { font-size: 11px; font-weight: 600; color: var(--text-mut); background: var(--bg-input); padding: 1px 7px; border-radius: 8px; }
.kanban-col-value { padding: 0 14px 12px; font-size: 13px; font-weight: 600; }
.kanban-cards { flex: 1; overflow-y: auto; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-card { background: var(--bg-panel); border-radius: 10px; padding: 12px; border: 1px solid var(--border); cursor: grab; box-shadow: var(--shadow-sm); transition: all .12s; }
.kanban-card:hover { border-color: var(--border-light); }
.kanban-card.dragging { opacity: .5; }
.kanban-card-title { font-size: 13px; font-weight: 500; }
.kanban-card-meta { font-size: 11px; color: var(--text-mut); margin-top: 2px; }
.kanban-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.kanban-empty { padding: 22px 12px; text-align: center; font-size: 12px; color: var(--text-dim); border: 1px dashed var(--border); border-radius: 10px; }

/* ============================================================
   FORMS / MODAL
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-mut); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: var(--bg-input); color: var(--text); transition: border-color .12s;
}
.form-control:focus { border-color: var(--accent); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; animation: fadeIn .1s; }
.modal { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; display: flex; flex-direction: column; max-height: 90vh; animation: slideUp .15s; }
.modal-lg { max-width: 680px; }
.modal-header { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ============================================================
   COMMAND PALETTE
   ============================================================ */
.cmd-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(2px); z-index: 1100; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; animation: fadeIn .1s; }
.cmd-box { width: 560px; max-width: 90vw; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; animation: slideUp .15s; }
.cmd-search { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.cmd-search input { flex: 1; background: transparent; border: none; font-size: 16px; }
.cmd-results { max-height: 360px; overflow-y: auto; padding: 8px; }
.cmd-group-label { font-size: 11px; font-weight: 700; color: var(--text-dim); padding: 8px 10px 4px; text-transform: uppercase; letter-spacing: .4px; }
.cmd-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border-radius: 9px; border: none; background: transparent; color: var(--text); font-size: 14px; cursor: pointer; text-align: left; }
.cmd-item:hover, .cmd-item.sel { background: var(--bg-hover); }
.cmd-item .ci-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--bg-input); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text-mut); }

/* ============================================================
   SETTINGS / CHANNEL ROWS
   ============================================================ */
.channel-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.channel-icon-box { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.connected-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--green); background: var(--green-dim); padding: 5px 12px; border-radius: 8px; }
.toggle { width: 40px; height: 22px; border-radius: 12px; background: var(--border); position: relative; cursor: pointer; transition: background .15s; flex-shrink: 0; border: none; }
.toggle.on { background: var(--accent); }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle.on::after { transform: translateX(18px); }

/* ============================================================
   TOAST / MISC
   ============================================================ */
.toast-container { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { display: flex; align-items: center; gap: 9px; padding: 12px 20px; border-radius: 11px; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-md); animation: slideIn .2s; background: var(--bg-panel); border: 1px solid var(--border); color: var(--text); }
.toast.success { background: var(--green); color: #fff; border: none; }
.toast.error { background: var(--red); color: #fff; border: none; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 60px 20px; color: var(--text-dim); gap: 12px; }
.empty-state .icon { font-size: 40px; opacity: .5; }
.empty-state p { font-size: 14px; }
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-mut); gap: 8px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
/* ============================================================
   DRAWER (detalhe de negócio)
   ============================================================ */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(2px); z-index: 130; display: flex; justify-content: flex-end; animation: fadeIn .1s; }
.drawer { width: 420px; max-width: 92vw; height: 100%; background: var(--bg-alt); border-left: 1px solid var(--border); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: drawerIn .18s ease; }
@keyframes drawerIn { from { transform: translateX(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.drawer-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-shrink: 0; }
.drawer-body { flex: 1; overflow-y: auto; }

/* ============================================================
   RESPONSIVO (celular ≤ 768px)
   ============================================================ */
.mobile-only { display: none; }

@media (max-width: 768px) {
  .mobile-only { display: inline-flex; }

  /* Rail vira barra de navegação inferior */
  #app { flex-direction: column; }
  .sidebar {
    flex-direction: row; width: 100%; height: 56px;
    position: fixed; bottom: 0; left: 0; z-index: 200;
    border-right: none; border-top: 1px solid var(--border);
    padding: 0 6px; gap: 0; justify-content: space-between; overflow-x: auto;
  }
  .sidebar-logo { display: none; }
  .sidebar-nav, .sidebar-bottom { flex-direction: row; align-items: center; gap: 0; }
  .nav-btn { width: 40px; height: 40px; flex-shrink: 0; }
  .nav-btn[data-tip]::after { display: none; }
  .avatar-btn { width: 32px; height: 32px; margin-top: 0; align-self: center; }

  .main { padding-bottom: 56px; min-width: 0; }

  /* Inbox: lista ocupa a tela; ao abrir conversa a thread cobre tudo */
  .conv-panel { width: 100%; }
  .main.thread-open .conv-panel { display: none; }
  .no-chat { display: none; }
  .thread { position: fixed; top: 0; left: 0; right: 0; bottom: 56px; z-index: 100; }
  .right-panel { position: fixed; top: 0; left: 0; right: 0; bottom: 56px; width: 100%; z-index: 120; }

  /* Telas cheias: padding e fontes menores */
  .content-header { padding: 16px; }
  .content-header h1 { font-size: 18px; }
  .content-header .sub { display: none; }
  .sub-tabs { padding: 0 12px; overflow-x: auto; }
  .content-body { padding: 16px; }
  .kanban-board { padding-bottom: 16px; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .modal { max-width: 100%; }
  .cmd-overlay { padding-top: 8vh; }
  .cmd-box { width: 92vw; }
}

[v-cloak] { display: none !important; }
