:root {
  --primary: #0047FF;
  --primary-dark: #0033CC;
  --primary-light: #3B82F6;
  --primary-gradient: linear-gradient(135deg, #3B82F6, #0033CC);
  --sidebar-bg: #07102B;
  --sidebar-hover: #0D1F4A;
  --sidebar-active: #0047FF;
  --surface: #FFFFFF;
  --surface-2: #F5F7FF;
  --surface-3: #EEF2FF;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
  --radius: 4px;
  --radius-sm: 2px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 10px 40px rgba(0,0,0,.1);
  --shadow-lg: 0 20px 60px rgba(0,71,255,.15);
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--surface-2);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Typography ── */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 4px;
  font-size: .875rem; font-weight: 600; cursor: pointer;
  border: none; transition: var(--transition); text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary); color: #fff;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--surface-3); color: var(--primary); }
.btn-secondary:hover { filter: brightness(.96); }
.btn-ghost { background: var(--surface-3); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.btn-icon { background: transparent; border: none; }
.btn-ghost.btn-icon:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-icon { padding: 8px; border-radius: 4px; }

/* ── Inputs ── */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: .8rem; font-weight: 600; color: var(--text-secondary); letter-spacing: .4px; }
.input-hint { font-size: .72rem; color: var(--text-muted); line-height: 1.4; }
.input {
  padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: .9rem; color: var(--text);
  background: var(--surface); transition: var(--transition); outline: none; width: 100%;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,71,255,.1); }
.input-icon-wrap { position: relative; }
.input-icon-wrap:has(.icon:not(.icon-right)) .input { padding-left: 40px; }
.input-icon-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-icon-wrap .icon-right { position: absolute; right: 12px; left: auto; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 16px; }
.input-icon-wrap:has(.icon-right) .input { padding-right: 40px; }
/* Input con checkbox prefijo */
.input-prefix-wrap { display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.input-prefix-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,71,255,.1); }
.input-prefix-wrap.prefix-disabled { opacity: .5; }
.input-prefix { display: flex; align-items: center; justify-content: center; padding: 0 12px; border-right: 1px solid var(--border); background: var(--surface-2); height: 100%; cursor: pointer; }
.input-prefix input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }
.input-prefix-wrap .input-icon-wrap .input { border: none; border-radius: 0; box-shadow: none; }
.input-prefix-wrap .input-icon-wrap .input:focus { border: none; box-shadow: none; }

/* ── Cards ── */
.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  font-size: .75rem; font-weight: 600;
}
.badge-blue { background: #EEF2FF; color: var(--primary); }
.badge-green { background: #ECFDF5; color: var(--success); }
.badge-yellow { background: #FFFBEB; color: var(--warning); }
.badge-red { background: #FEF2F2; color: var(--danger); }
.badge-gray { background: var(--surface-3); color: var(--text-secondary); }
.badge-dot::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor; display: inline-block;
}

/* ── Avatar ── */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; flex-shrink: 0;
  background: var(--primary-gradient); color: #fff;
}
.avatar-lg { width: 44px; height: 44px; font-size: .95rem; }
.avatar-sm { width: 28px; height: 28px; font-size: .7rem; }

/* ── Channel icons ── */
.channel-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--surface-3); color: var(--text-secondary);
}
.channel-whatsapp { background: #DCFCE7; color: #16A34A; }
.channel-whatsapp_qr { background: #FFFFFF; color: #111111; border: 1px solid #E5E7EB; }
.channel-whatsapp_api { background: #FFFFFF; color: #16A34A; border: 1px solid #E5E7EB; }
.channel-telegram { background: #DBEAFE; color: #2563EB; }
.channel-facebook { background: #EDE9FE; color: #7C3AED; }
.channel-instagram { background: #FEE2E2; color: #DC2626; }
.channel-webchat { background: #EEF2FF; color: #0047FF; }
.channel-phone { background: #ECFDF5; color: #059669; }
.channel-sms { background: #FEF3C7; color: #D97706; border: 1px solid #FDE68A; }
.channel-email { background: #F5F3FF; color: #7C3AED; border: 1px solid #DDD6FE; }

/* ── App Shell ── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--sidebar-bg);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width var(--transition);
}
.sidebar.collapsed { width: 64px; }

.sidebar-logo {
  padding: 16px; display: flex; align-items: center; justify-content: center; gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,.07); flex-shrink: 0;
}
.sidebar-logo img { flex-shrink: 0; }
.sidebar-logo-text {
  font-size: 1.1rem; font-weight: 800; color: #fff;
  white-space: nowrap; overflow: hidden;
}
.sidebar-logo-text span { color: var(--primary-light); }
.sidebar.collapsed .sidebar-logo-text { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 8px; }

.nav-section { margin-bottom: 4px; }
.nav-section-label {
  padding: 8px 10px 4px;
  font-size: .65rem; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: rgba(255,255,255,.3);
  white-space: nowrap; overflow: hidden;
}
.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6); text-decoration: none;
  font-size: .8125rem; font-weight: 500; cursor: pointer;
  transition: var(--transition); position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item-danger { color: #ff6b6b !important; }
.nav-item-danger:hover { background: rgba(255,80,80,.2) !important; color: #ff6b6b !important; }
.nav-item.active { background: var(--sidebar-active); color: #fff; box-shadow: 0 4px 12px rgba(0,71,255,.4); }

/* Variante para usar dentro de cards claros (ej: Settings) */
.nav-item-light {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none;
  font-size: .875rem; font-weight: 500; cursor: pointer;
  transition: var(--transition); white-space: nowrap;
}
.nav-item-light:hover { background: var(--surface-3); color: var(--text); }
.nav-item-light.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(0,71,255,.25); }
.nav-item svg { flex-shrink: 0; }
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.nav-item .nav-chevron { margin-left: auto; opacity: .6; flex-shrink: 0; transition: transform .2s; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-chevron { display: none; }
.nav-children { background: rgba(0,0,0,.15); }
.nav-child { padding-left: 36px !important; font-size: .82rem; opacity: .9; }
.nav-grandchild { padding-left: 52px !important; font-size: .8rem; opacity: .85; }

.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 99px; display: flex; align-items: center; justify-content: center;
  padding: 0 5px; line-height: 1; box-sizing: border-box; flex-shrink: 0;
}
.sidebar.collapsed .nav-badge { position: absolute; top: 4px; right: 4px; }

.sidebar-footer {
  padding: 12px 8px; border-top: 1px solid rgba(255,255,255,.07);
}
.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: default; transition: var(--transition);
}
.user-info { overflow: hidden; flex: 1; }
.user-info .name { font-size: .85rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { font-size: .72rem; color: rgba(255,255,255,.4); white-space: nowrap; }
.sidebar.collapsed .user-info { display: none; }
.user-menu-btn { color: rgba(255,255,255,.5) !important; }
.user-menu-btn:hover { color: #fff !important; background: rgba(255,255,255,.1) !important; }
.user-menu {
  position: absolute; bottom: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: 0 -4px 16px rgba(0,0,0,.15);
  z-index: 200; overflow: hidden;
}
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; font-size: .875rem; color: var(--text);
  cursor: pointer; transition: background .15s;
}
.user-menu-item:hover { background: var(--surface-3); }
.user-menu-danger { color: #ef4444 !important; }
.user-menu-danger:hover { background: rgba(239,68,68,.08) !important; }

/* ── Main content ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px; flex-shrink: 0;
}
.topbar-title { font-weight: 700; font-size: 1rem; color: var(--text); }
.topbar-spacer { flex: 1; }
.topbar-btn { width: 36px !important; height: 36px !important; padding: 0 !important; justify-content: center; }

.bell-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 290px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 20px rgba(0,0,0,.15);
  z-index: 300; padding: 4px 0 8px;
}
.bell-menu-title {
  font-size: .78rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 16px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.bell-menu-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; gap: 12px; font-size: .875rem; cursor: default;
}
.bell-menu-row span:first-child { display: flex; align-items: center; gap: 8px; }
.bell-menu-note { font-size: .73rem; color: var(--text-muted); margin: 4px 16px 0; line-height: 1.4; }
.toggle-track {
  flex-shrink: 0; width: 40px; height: 22px; border-radius: 11px;
  background: var(--surface-3); display: inline-block; position: relative;
  cursor: pointer; transition: background .2s;
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: left .2s;
}

.page { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Stats grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
}
.stat-card .stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-card .stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.stat-card .stat-delta { font-size: .75rem; font-weight: 600; display: flex; align-items: center; gap: 3px; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ── Conversations ── */
.conv-layout { display: flex; height: 100%; gap: 0; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.conv-state-sel { width: 100%; padding: 6px 8px; font-size: .82rem; font-weight: 600; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); cursor: pointer; outline: none; }
.conv-list { width: 320px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.conv-list-header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.conv-list-header h2 { font-size: .95rem; }
.conv-search { position: relative; }
.conv-search input { width: 100%; padding: 7px 12px 7px 32px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .82rem; outline: none; transition: var(--transition); }
.conv-search input:focus { border-color: var(--primary); }
.conv-search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.conv-filters { display: flex; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.conv-filter-btn { padding: 4px 12px; border-radius: 99px; font-size: .75rem; font-weight: 600; cursor: pointer; border: 1.5px solid var(--border); background: transparent; color: var(--text-secondary); white-space: nowrap; transition: var(--transition); }
.conv-filter-btn.active { border-color: var(--primary); background: #EEF2FF; color: var(--primary); }
.conv-items { flex: 1; overflow-y: auto; }
.conv-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; transition: var(--transition); border-bottom: 1px solid var(--border); }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--surface-3); }
.conv-item-body { flex: 1; overflow: hidden; }
.conv-item-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px; }
.conv-item-name { font-size: .875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item-time { font-size: .72rem; color: var(--text-muted); flex-shrink: 0; }
.conv-item-preview { font-size: .8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Chat area ── */
.chat-area { flex: 1; display: flex; flex-direction: column; }
.chat-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.chat-contact-info .name { font-weight: 700; font-size: .9rem; }
.chat-contact-info .status { font-size: .75rem; color: var(--success); display: flex; align-items: center; gap: 4px; }
.chat-contact-info .status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--success); display: inline-block; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; position: relative; background-color: #e5ddd5; background-image: url('/static/assets/chat-bg-pattern.svg'); background-repeat: repeat; background-size: 280px 280px; }
.chat-messages::before { content: ''; position: absolute; inset: 0; background: url('/static/assets/logo-light.png') center/140px auto no-repeat; opacity: 0.04; pointer-events: none; z-index: 0; }
.chat-messages > * { position: relative; z-index: 1; }
.message { max-width: 70%; display: flex; flex-direction: column; gap: 2px; }
.message.out { align-self: flex-end; align-items: flex-end; }
.message.in { align-self: flex-start; }
.message-bubble { position: relative; padding: 7px 12px 4px; border-radius: 12px; font-size: .875rem; line-height: 1.5; word-break: break-word; max-width: 100%; }
.message.in .message-bubble { background: #ffffff; box-shadow: 0 1px 1px rgba(0,0,0,.12); border-radius: 0 12px 12px 12px; }
.message.in .message-bubble::before { content: ''; position: absolute; top: 0; left: -7px; border: 7px solid transparent; border-top-color: #ffffff; border-right-color: #ffffff; }
.message.out .message-bubble { background: #d9fdd3; box-shadow: 0 1px 1px rgba(0,0,0,.12); border-radius: 12px 0 12px 12px; }
.message.out .message-bubble::before { content: ''; position: absolute; top: 0; right: -7px; border: 7px solid transparent; border-top-color: #d9fdd3; border-left-color: #d9fdd3; }
.message-meta { font-size: .67rem; color: #8696a0; display: flex; align-items: center; justify-content: flex-end; gap: 3px; margin-top: 3px; line-height: 1; }
.message.out .message-meta { color: #667781; }
.message.out .msg-status { color: #53bdeb; display: inline-flex; align-items: center; }
.message.out .msg-status[data-status="sent"], .message.out .msg-status[data-status="delivered"] { color: #8696a0; }
.message.out .msg-status[data-status="failed"] { color: var(--danger); }
.message.out .msg-status svg { pointer-events: none; }
.message.out .msg-status[data-err] { cursor: pointer; padding: 3px; margin: -3px; border-radius: 50%; }
.message.out .msg-status[data-err]:hover { background: rgba(0,0,0,.1); }
.msg-agent-name { font-size: .68rem; font-weight: 600; opacity: .8; padding-right: 5px; border-right: 1px solid rgba(0,0,0,.2); margin-right: 2px; }
.chat-input-area { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; align-items: flex-end; gap: 10px; }
.chat-input-area textarea { flex: 1; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; resize: none; outline: none; font-family: inherit; transition: var(--transition); max-height: 120px; }
.chat-input-area textarea:focus { border-color: var(--primary); }

/* ── Conversations — right panel, reply, media ── */
.conv-right-panel { width: 320px; flex-shrink: 0; border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; background: var(--surface); }
.rp-contact-header { padding: 18px 14px 12px; border-bottom: 1px solid var(--border); text-align: center; }
.rp-contact-avatar { width: 50px; height: 50px; border-radius: 50%; background: var(--primary-gradient); color: #fff; font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; }
.rp-contact-name { font-size: .875rem; font-weight: 700; }
.rp-contact-sub { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.rp-section { border-bottom: 1px solid var(--border); }
.rp-section-hdr { padding: 9px 14px; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; color: var(--text-secondary); user-select: none; }
.rp-section-hdr:hover { background: var(--surface-2); }
.rp-section-hdr .rp-arr { margin-left: auto; transition: var(--transition); }
.rp-section.open .rp-arr { transform: rotate(180deg); }
.rp-section-body { padding: 8px 14px 12px; display: none; font-size: .8rem; }
.rp-section.open .rp-section-body { display: block; }
.rp-field { display: flex; gap: 6px; margin-bottom: 5px; }
.rp-label { color: var(--text-muted); white-space: nowrap; min-width: 70px; }
.rp-val { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.reply-ctx { background: var(--surface-2); border-left: 3px solid var(--primary); padding: 5px 10px; font-size: .78rem; color: var(--text-muted); align-items: center; justify-content: space-between; margin: 0 20px; }
.message:hover .msg-reply-btn { opacity: 1; }
.msg-reply-btn { opacity: 0; background: var(--surface); border: 1.5px solid var(--border); border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: opacity .15s; flex-shrink: 0; }
.msg-quote-block { background: rgba(0,0,0,.08); border-left: 3px solid var(--primary); border-radius: 4px; padding: 5px 8px; margin-bottom: 5px; font-size: .78rem; color: var(--text-muted); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.message.out .msg-quote-block { background: rgba(0,0,0,.12); border-left-color: rgba(255,255,255,.5); }
.msg-highlight { animation: msgHighlight 1.5s ease; }
@keyframes msgHighlight { 0%,100% { background: transparent; } 20%,70% { background: rgba(0,71,255,.15); border-radius: 8px; } }
.conv-filter-dd { position: relative; display: inline-block; }
.conv-filter-dd .dd-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 200; min-width: 180px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); padding: 4px 0; display: none; max-height: 200px; overflow-y: auto; }
.conv-filter-dd.open .dd-menu { display: block; }
.dd-item { padding: 6px 12px; font-size: .8rem; cursor: pointer; white-space: nowrap; }
.dd-item:hover { background: var(--surface-2); }
.dd-item.sel { color: var(--primary); font-weight: 600; }
.msg-media-img { max-width: 260px; width: 100%; border-radius: 8px; cursor: pointer; display: block; margin: 2px 0; }
.msg-media-audio { display: block; width: 240px; height: 40px; }
.msg-media-video { max-width: 260px; width: 100%; border-radius: 8px; }
.tpl-list-item:hover { background: var(--surface-2); }
.badge-red { background: rgba(239,68,68,.15); color: #ef4444; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
.table-wrap thead th:last-child,
.col-sticky { position: sticky; right: 0; z-index: 2; background: var(--surface-2); box-shadow: -2px 0 6px rgba(0,0,0,.06); }
.table-wrap tbody td:last-child,
tbody tr td.col-sticky { position: sticky; right: 0; z-index: 2; background: var(--surface); box-shadow: -2px 0 6px rgba(0,0,0,.06); }
.table-wrap tbody tr:hover td:last-child,
tbody tr:hover td.col-sticky { background: var(--surface-2); }
table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th { padding: 10px 16px; text-align: center; font-size: .75rem; font-weight: 600; color: var(--text-muted); letter-spacing: 0; text-transform: capitalize; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text); white-space: nowrap; }
tbody td:last-child { text-align: center; }
tbody td:last-child > div { justify-content: center; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.pg-bar { display:flex; align-items:center; gap:16px; padding:10px 16px; border-top:1px solid var(--border); font-size:.8rem; color:var(--text-muted); flex-wrap:wrap; }
.pg-info { margin-right:auto; }
.pg-size { display:flex; align-items:center; gap:6px; }
.pg-size select { padding:3px 6px; border:1px solid var(--border); border-radius:var(--radius-sm); font-size:.8rem; background:var(--surface); color:var(--text); cursor:pointer; }
.pg-nav { display:flex; align-items:center; gap:2px; }
.pg-nav span { padding:0 8px; font-size:.82rem; }
.pg-nav button { width:28px; height:28px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface); color:var(--text); cursor:pointer; display:flex; align-items:center; justify-content:center; transition:var(--transition); }
.pg-nav button:hover:not(:disabled) { background:var(--surface-2); }
.pg-nav button:disabled { opacity:.35; cursor:not-allowed; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; pointer-events: none; transition: var(--transition); }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 28px; width: 90%; max-width: 480px; transform: translateY(12px); transition: var(--transition); }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: flex-end; position: relative; margin-bottom: 20px; }
.modal-header .modal-title { position: absolute; left: 0; right: 0; text-align: center; pointer-events: none; }
.modal-footer { display: flex; gap: 10px; margin-top: 24px; }
.modal-footer .btn { flex: 1; justify-content: center; }

/* ── Login ── */
.login-screen {
  min-height: 100vh; display: flex; align-items: stretch;
  background: var(--surface);
}
.login-left {
  flex: 1; background: var(--sidebar-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px; position: relative; overflow: hidden;
}
.login-left::before {
  content: ''; position: absolute; width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(0,71,255,.25) 0%, transparent 70%);
  top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; position: relative; z-index: 1; }
.login-brand-identity { display: flex; flex-direction: column; align-items: center; gap: 0; }
.login-brand h1 { color: #fff; font-size: 2rem; font-weight: 800; }
.login-brand h1 span { color: var(--primary-light); }
.login-tagline { color: rgba(255,255,255,.5); font-size: .95rem; max-width: 340px; line-height: 1.6; }
.login-channels { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.login-channel-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 99px;
  background: rgba(255,255,255,.07); color: rgba(255,255,255,.7);
  font-size: .78rem; font-weight: 500; border: 1px solid rgba(255,255,255,.1);
}

.login-right {
  width: 480px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 56px;
}
.login-form-wrap { width: 100%; }
.login-form-wrap h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; }
.login-form-wrap p { color: var(--text-muted); font-size: .875rem; margin-bottom: 32px; }
.login-form-wrap .form-fields { display: flex; flex-direction: column; gap: 18px; }
.login-form-wrap .btn-primary { width: 100%; justify-content: center; padding: 13px; font-size: .95rem; margin-top: 8px; }
.login-error { background: #FEF2F2; border: 1px solid #FECACA; color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); font-size: .85rem; display: none; margin-bottom: 16px; }
.login-error.show { display: block; }

/* ── Channels page ── */
.channels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.channel-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; transition: var(--transition); }
.channel-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.channel-card-header { display: flex; align-items: center; gap: 12px; }
.channel-card-header h3 { font-size: .95rem; font-weight: 700; }
.channel-card-header .badge { margin-left: auto; }
.channel-card p { font-size: .82rem; color: var(--text-muted); line-height: 1.6; }
.channel-card-footer { display: flex; gap: 8px; margin-top: auto; }

/* ── Toast ── */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast { background: var(--text); color: #fff; padding: 12px 18px; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 500; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 10px; animation: slideIn .3s ease; min-width: 260px; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rec-pulse { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:.4; transform:scale(.7); } }
.spinner-sm { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle; opacity: .7; }

/* ── Sidebar toggle button ── */
.toggle-sidebar { background: none; border: none; cursor: pointer; color: rgba(255,255,255,.6); padding: 4px; border-radius: 6px; transition: var(--transition); display: flex; }
.toggle-sidebar:hover { color: #fff; background: rgba(255,255,255,.1); }

/* ── Softphone flotante ── */
.sp-panel {
  position: fixed; bottom: 24px; right: 24px; z-index: 9000;
  width: 320px; background: var(--sidebar-bg);
  border-radius: var(--radius); box-shadow: 0 24px 64px rgba(0,0,0,.5);
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid rgba(255,255,255,.08);
  color: #fff; font-family: inherit;
}
.sp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.04);
}
.sp-status-row { display: flex; align-items: center; gap: 9px; }
.sp-reg-label { font-size: .78rem; font-weight: 600; color: rgba(255,255,255,.65); }
.sp-close-btn {
  background: none; border: none; color: rgba(255,255,255,.4);
  cursor: pointer; font-size: .95rem; line-height: 1; padding: 4px 6px;
  border-radius: 6px; transition: var(--transition);
}
.sp-close-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

/* Toggle switch */
.sp-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.sp-switch input { opacity: 0; width: 0; height: 0; }
.sp-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: rgba(255,255,255,.15); border-radius: 24px; transition: background .25s;
}
.sp-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  left: 3px; top: 3px; transition: transform .25s;
}
.sp-switch input:checked + .sp-slider { background: var(--success); }
.sp-switch input:checked + .sp-slider::before { transform: translateX(18px); }

.sp-tabs-bar { display: flex; border-bottom: 1px solid rgba(255,255,255,.07); }
.sp-tab-btn {
  flex: 1; padding: 9px 0; background: none; border: none; color: rgba(255,255,255,.45);
  font-size: .78rem; font-weight: 600; cursor: pointer; transition: var(--transition);
  border-bottom: 2px solid transparent;
}
.sp-tab-btn:hover { color: rgba(255,255,255,.8); }
.sp-tab-btn.active { color: #fff; border-bottom-color: var(--primary-light); }

#sp-tab-call, #sp-tab-history { padding: 16px; }

.sp-display {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.07); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 14px;
}
.sp-num-input {
  flex: 1; background: none; border: none; outline: none;
  color: #fff; font-size: 1.1rem; font-weight: 600; letter-spacing: 2px; font-family: inherit;
}
.sp-num-input::placeholder { color: rgba(255,255,255,.25); font-weight: 400; font-size: .85rem; letter-spacing: 0; }
.sp-back-btn {
  background: none; border: none; color: rgba(255,255,255,.4); cursor: pointer;
  font-size: 1rem; padding: 2px 4px; border-radius: 4px; transition: var(--transition);
}
.sp-back-btn:hover { color: #fff; }
.sp-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.sp-keypad-sm { gap: 5px; margin-bottom: 0; }
.sp-key {
  background: rgba(255,255,255,.08); border: none; border-radius: var(--radius-sm);
  color: #fff; cursor: pointer; padding: 12px 0;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  transition: var(--transition); font-family: inherit;
}
.sp-key span { font-size: 1.05rem; font-weight: 600; line-height: 1; }
.sp-key sub  { font-size: .5rem; color: rgba(255,255,255,.4); letter-spacing: 1px; }
.sp-key:hover  { background: rgba(255,255,255,.15); }
.sp-key:active { transform: scale(.94); }
.sp-key-sm { padding: 9px 0; }
.sp-key-sm span { font-size: .9rem; }
.sp-main-actions { display: flex; justify-content: center; gap: 16px; margin-top: 4px; }
.sp-fab {
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff; transition: var(--transition); box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.sp-fab:active { transform: scale(.93); }
.sp-fab-call   { background: var(--success); }
.sp-fab-call:hover { background: #0da375; }
.sp-fab-answer { background: var(--success); }
.sp-fab-hangup { background: var(--danger); }
.sp-fab-hangup:hover { background: #dc2626; }
.sp-caller-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; background: rgba(255,255,255,.05);
  border-radius: var(--radius-sm); margin-bottom: 14px;
}
.sp-caller-avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-gradient); display: flex; align-items: center;
  justify-content: center; font-size: 1.2rem; font-weight: 700;
}
.sp-caller-name    { font-size: .95rem; font-weight: 700; margin-bottom: 2px; }
.sp-call-state-lbl { font-size: .75rem; color: rgba(255,255,255,.5); }
.sp-timer { font-size: 1rem; font-weight: 700; color: var(--success); margin-top: 2px; }
.sp-action-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.sp-action-btn {
  background: rgba(255,255,255,.08); border: none; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7); cursor: pointer; padding: 10px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: .62rem; font-weight: 600; letter-spacing: .3px; transition: var(--transition); font-family: inherit;
}
.sp-action-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.sp-btn-active { background: var(--primary) !important; color: #fff !important; }
.sp-sub-panel { background: rgba(255,255,255,.06); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; }
.sp-history { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.sp-hist-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition);
}
.sp-hist-row:hover { background: rgba(255,255,255,.07); }

/* ── PBX Panel ── */
.pbx-layout { display: flex; height: calc(100vh - 108px); gap: 0; }
.pbx-subnav {
  width: 200px; flex-shrink: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px; display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto; height: fit-content; max-height: 100%;
}
.pbx-subnav-section { padding: 10px 8px 4px; font-size: .63rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); }
.pbx-content { flex: 1; overflow-y: auto; padding-left: 16px; }

/* ── PBX Form ── */
.pbx-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.pbx-form-title { font-size: 1rem; font-weight: 700; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.pbx-form-actions { display: flex; gap: 10px; margin-top: 24px; }
.pbx-form-actions .btn { flex: 1; justify-content: center; }
.form-section-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .span2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; }
/* Settings sections */
.ps-form-expanded { display: flex; flex-direction: column; gap: 20px; }
.ps-section { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ps-section-title { font-size: .85rem; font-weight: 600; color: var(--text-muted); background: var(--bg); padding: 10px 16px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.ps-section .form-grid { padding: 16px; }
.ps-codec-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.ps-codec-item { display: flex; align-items: center; gap: 6px; font-size: .85rem; cursor: pointer; padding: 4px 10px; border: 1px solid var(--border); border-radius: 2px; background: var(--bg); }
.ps-codec-item:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); }
.codec-picker-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 4px; }
.codec-col-label { font-size: .78rem; color: var(--text-muted); margin-bottom: 6px; }
.codec-selected { display: flex; flex-direction: column; gap: 4px; min-height: 60px; border: 1px solid var(--border); border-radius: 2px; padding: 6px; background: var(--bg-alt); }
.codec-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); font-size: .82rem; font-weight: 500; cursor: grab; user-select: none; }
.codec-item:active { cursor: grabbing; }
.codec-avail { display: flex; flex-direction: column; gap: 4px; min-height: 60px; border: 1px solid var(--border); border-radius: 2px; padding: 6px; background: var(--bg-alt); }
.codec-chip { display: flex; align-items: center; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); font-size: .82rem; font-weight: 500; cursor: pointer; color: var(--text-muted); text-align: left; transition: border-color .12s, color .12s; width: 100%; }
.codec-chip:hover { border-color: var(--primary); color: var(--primary); }

/* ── Feature icons (extension table) ── */
.feat-row { display: flex; align-items: center; justify-content: center; gap: 6px; }
.feat-icon { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 6px; }
.feat-blue   { color: var(--primary);  background: color-mix(in srgb, var(--primary) 12%, transparent); }
.feat-gray   { color: var(--text-muted); background: var(--surface-2); }
.feat-red    { color: var(--danger);   background: color-mix(in srgb, var(--danger)  12%, transparent); }
.feat-purple { color: #7c3aed;         background: color-mix(in srgb, #7c3aed        12%, transparent); }
.feat-green  { color: var(--success);  background: color-mix(in srgb, var(--success) 12%, transparent); }
.feat-orange { color: #ea580c;         background: color-mix(in srgb, #ea580c        12%, transparent); }

/* ── Call forwarding ── */
.cf-table { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cf-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.cf-row:last-child { border-bottom: none; }
.cf-label { font-size: .8rem; font-weight: 600; color: var(--text-secondary); width: 110px; flex-shrink: 0; }
.cf-toggle { display: flex; align-items: center; justify-content: center; padding: 0 8px; flex-shrink: 0; }
.cf-toggle input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }

/* ── Status indicator ── */
.ami-status { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; }
.ami-status-dot { width: 8px; height: 8px; border-radius: 50%; }
.ami-status-dot.connected { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.ami-status-dot.disconnected { background: var(--danger); }

/* ── Active calls panel ── */
.active-calls-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.call-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.call-card-header { display: flex; align-items: center; gap: 10px; }
.call-card-channel { font-size: .78rem; font-weight: 700; color: var(--text-muted); }
.call-card-number { font-size: 1rem; font-weight: 700; }
.call-duration { font-size: .75rem; color: var(--text-muted); margin-left: auto; }
.call-card-footer { display: flex; gap: 6px; }

/* ── Softphone ── */
.softphone {
  background: var(--sidebar-bg); border-radius: var(--radius);
  padding: 24px; max-width: 280px; margin: 0 auto;
}
.softphone-display {
  background: rgba(255,255,255,.07); border-radius: var(--radius-sm);
  padding: 16px; text-align: right; margin-bottom: 16px;
}
.softphone-number { font-size: 1.6rem; font-weight: 700; color: #fff; min-height: 44px; word-break: break-all; }
.softphone-status { font-size: .75rem; color: rgba(255,255,255,.4); }
.dialpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.dialpad-btn {
  background: rgba(255,255,255,.08); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 16px; font-size: 1.1rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.dialpad-btn sub { font-size: .55rem; font-weight: 400; opacity: .5; }
.dialpad-btn:hover { background: rgba(255,255,255,.15); }
.dialpad-btn:active { transform: scale(.95); }
.dialpad-call { background: var(--success); box-shadow: 0 4px 12px rgba(16,185,129,.4); }
.dialpad-call:hover { background: #0da375; }
.dialpad-hangup { background: var(--danger); box-shadow: 0 4px 12px rgba(239,68,68,.4); }
.dialpad-hangup:hover { background: #dc2626; }

/* ── CDR table extras ── */
.cdr-in { color: var(--success); }
.cdr-out { color: var(--info); }
.cdr-missed { color: var(--danger); }

/* ── IVR tree ── */
.ivr-options { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ivr-option-row { display: flex; align-items: center; gap: 10px; }
.ivr-key-badge {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-gradient); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; flex-shrink: 0;
}

/* ── Select ── */
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; cursor: pointer; }

/* ── Toggle switch ── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 99px; cursor: pointer; transition: var(--transition); }
.toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: var(--transition); }
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Roles layout ── */
.roles-layout { display: flex; gap: 16px; align-items: flex-start; height: calc(100vh - 160px); }
.roles-sidebar { width: 260px; flex-shrink: 0; display: flex; flex-direction: column; height: 100%; }
.roles-main { flex: 1; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); height: 100%; overflow: hidden; }
.role-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--border);
  font-size: .875rem; transition: var(--transition);
}
.role-list-item:hover { background: var(--surface-2); }
.role-list-item.active { background: rgba(0,71,255,.07); color: var(--primary); font-weight: 600; border-left: 3px solid var(--primary); }

/* ── Permission checkboxes ── */
.perm-sections { display: flex; flex-direction: column; gap: 16px; }
.perm-cat-label { font-size: .7rem; font-weight: 700; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 6px; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.perm-subgrid { margin-left: 24px; background: var(--surface-2); border-radius: 2px; padding: 10px 12px; border: 1px solid var(--border); }
.perm-group-header { padding-bottom: 6px; }
.perm-check { display: flex; align-items: center; gap: 8px; font-size: .85rem; cursor: pointer; }
.perm-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }

/* ── User form tabs ── */
.user-form-tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  margin-bottom: 20px; padding-bottom: 0;
}
.user-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; background: none; cursor: pointer;
  color: var(--text-muted); font-size: .875rem; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  border-radius: 6px 6px 0 0; transition: var(--transition);
}
.user-tab:hover { color: var(--text); background: var(--surface-2); }
.user-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Group selector buttons (legacy, still used in groups page) ── */
.group-btn-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.group-btn {
  padding: 5px 14px; border-radius: 99px; border: 1.5px solid var(--border);
  background: var(--surface-2); color: var(--text-secondary); cursor: pointer;
  font-size: .82rem; font-weight: 500; transition: var(--transition);
}
.group-btn:hover { border-color: var(--primary); color: var(--primary); }
.group-btn.active { border-color: var(--primary); background: rgba(0,71,255,.08); color: var(--primary); }


/* ── Multiselect de grupos ── */
.ms-wrap { position: relative; }
.ms-trigger {
  display: flex; align-items: center; gap: 8px; min-height: 40px;
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; background: var(--surface-2); transition: border-color .15s;
}
.ms-trigger:hover, .ms-wrap.open .ms-trigger { border-color: var(--primary); }
.ms-tags  { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; align-items: center; }
.ms-tag   {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px; font-size: .78rem; font-weight: 600;
  border: 1px solid; white-space: nowrap;
}
.ms-tag-remove { cursor: pointer; opacity: .6; font-size: 1rem; line-height: 1; margin-left: 2px; }
.ms-tag-remove:hover { opacity: 1; }
.ms-placeholder { color: var(--text-muted); font-size: .875rem; padding: 2px 0; }
.ms-chevron { flex-shrink: 0; color: var(--text-muted); transition: transform .2s; }
.ms-wrap.open .ms-chevron { transform: rotate(180deg); }
.ms-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 2px;
  box-shadow: 0 8px 28px rgba(0,0,0,.14); z-index: 300; overflow: hidden;
  animation: fadeIn .12s ease;
}
.ms-option {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; cursor: pointer; user-select: none; transition: background .1s;
}
.ms-option:hover { background: var(--surface-2); }
.ms-option input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; flex-shrink: 0; cursor: pointer; }
.ms-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: .85rem; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .sidebar .nav-label, .sidebar .nav-section-label, .sidebar .sidebar-logo-text, .sidebar .user-info { display: none; }
  .login-left { display: none; }
  .login-right { width: 100%; padding: 40px 32px; }
  .pbx-layout { flex-direction: column; height: auto; }
  .pbx-subnav { width: 100%; flex-direction: row; flex-wrap: wrap; height: auto; }
  .pbx-content { padding-left: 0; padding-top: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease;
}
.modal-box {
  background: var(--surface); border-radius: 4px;
  padding: 32px 28px 24px; width: 360px; max-width: calc(100vw - 32px);
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  animation: scaleIn .18s cubic-bezier(.34,1.56,.64,1);
}
.modal-icon {
  width: 60px; height: 60px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.modal-icon.danger { background: rgba(239,68,68,.12); color: var(--danger); }
.modal-icon.info   { background: rgba(0,71,255,.1);   color: var(--primary); }
.modal-title { font-size: 1.05rem; font-weight: 700; color: var(--text); text-align: center; }
.modal-msg   { font-size: .9rem; color: var(--text-muted); text-align: center; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; width: 100%; }
.modal-actions .btn { flex: 1; justify-content: center; }
.btn-danger { background: var(--danger); color: #fff; border: none; }
/* Multiselect de etiquetas */
.cf-ms { position:relative; display:flex; align-items:center; gap:6px; min-height:38px; padding:4px 10px 4px 8px; border:1.5px solid var(--border); background:var(--surface); cursor:pointer; transition:border-color .15s; }
.cf-ms:focus-within, .cf-ms:hover { border-color: var(--primary); }
.cf-ms-values { display:flex; flex-wrap:wrap; gap:5px; flex:1; min-width:0; }
.cf-ms-chip { display:inline-flex; align-items:center; font-size:.75rem; font-weight:600; padding:2px 7px; border-radius:2px; }
.cf-ms-placeholder { font-size:.85rem; color:var(--text-muted); padding:2px 0; }
.cf-ms-drop { position:absolute; top:calc(100% + 2px); left:-1px; right:-1px; background:var(--surface); border:1.5px solid var(--primary); border-top:none; z-index:500; max-height:200px; overflow-y:auto; }
.cf-ms-opt { display:flex; align-items:center; gap:8px; padding:8px 12px; font-size:.85rem; cursor:pointer; transition:background .1s; }
.cf-ms-opt:hover { background:var(--surface-2); }
.cf-ms-chk { margin-left:auto; color:var(--primary); display:none; }
.cf-ms-opt.sel .cf-ms-chk { display:block; }
/* Form elements used in modals and panels */
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.form-input { display: block; width: 100%; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; background: var(--surface); color: var(--text); font-family: inherit; outline: none; transition: border-color .15s; resize: vertical; box-sizing: border-box; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,71,255,.08); }
.form-hint { display: block; font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
.modal-form { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.modal-form-row { display: flex; flex-direction: column; }
.btn-danger:hover { background: #c0392b; }
@keyframes scaleIn {
  from { transform: scale(.85); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.em-folder-custom:hover .em-folder-del { display: block !important; }
.em-folder-custom:hover { background: var(--surface-2, rgba(0,0,0,.04)); }

/* ── Kanban board ────────────────────────────────── */
.kanban-board { display:flex; gap:16px; overflow-x:auto; padding-bottom:16px; align-items:flex-start; }
.kanban-column { flex:0 0 280px; display:flex; flex-direction:column; border-radius:8px; overflow:hidden; border:1px solid var(--border); background:var(--surface-2); transition:background .15s,border-color .15s; }
.kanban-column.kanban-drag-over { background:color-mix(in srgb,var(--primary) 8%,var(--surface-2)); border-color:var(--primary); }
.kanban-col-header { padding:12px 14px; background:var(--surface); display:flex; align-items:center; justify-content:space-between; font-weight:600; font-size:.875rem; gap:8px; }
.kanban-col-body { flex:1; padding:8px; display:flex; flex-direction:column; gap:8px; min-height:80px; }
.kanban-card { background:var(--surface); border-radius:6px; padding:12px 14px; cursor:grab; border:1px solid var(--border); transition:box-shadow .12s,transform .12s; }
.kanban-card:active { cursor:grabbing; transform:rotate(1deg); box-shadow:0 4px 16px rgba(0,0,0,.15); }
.kanban-card:hover { box-shadow:0 2px 8px rgba(0,0,0,.08); }
.kanban-card-name { font-weight:500; font-size:.875rem; margin-bottom:2px; }
.kanban-card-sub { font-size:.75rem; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.kanban-card-actions { display:flex; justify-content:flex-end; gap:4px; margin-top:8px; padding-top:8px; border-top:1px solid var(--border); }
.kanban-card-btn { display:flex; align-items:center; justify-content:center; width:26px; height:26px; border:1px solid var(--border); border-radius:5px; background:var(--surface-2); color:var(--text-secondary); cursor:pointer; transition:background .12s,color .12s; }
.kanban-card-btn:hover { background:var(--primary); color:#fff; border-color:var(--primary); }
.kanban-card-btn-danger:hover { background:var(--danger); border-color:var(--danger); }

/* ── Control de Tiempos ─────────────────────────── */
.tc-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--sidebar-bg);
  display: flex; align-items: center; justify-content: center;
}
.tc-overlay-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 16px; padding: 48px 40px; max-width: 420px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: scaleIn .25s ease;
}
.tc-overlay-greeting { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; }
.tc-overlay-subtitle { font-size: .9rem; color: var(--text-muted); margin-bottom: 32px; line-height: 1.5; }
.tc-overlay-btn { padding: 14px 32px; font-size: 1rem; gap: 10px; }

.tc-topbar-indicator {
  display: flex; align-items: center; gap: 4px;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}
