* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f172a; color: #e2e8f0; min-height: 100vh;
}

/* Nav */
.nav {
    background: #1e293b; border-bottom: 1px solid #334155;
    padding: 0 24px; height: 52px; display: flex;
    align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 100;
}
.nav-left { display: flex; align-items: center; gap: 16px; }
.nav-logo { font-size: 18px; font-weight: 700; color: #f1f5f9; text-decoration: none; }
.nav-logo span { color: #3b82f6; }
.nav-tabs { display: flex; gap: 4px; margin-left: 24px; }
.nav-tab {
    background: none; border: none; color: #94a3b8;
    padding: 8px 16px; border-radius: 6px; cursor: pointer;
    font-size: 14px; font-weight: 600; transition: all 0.15s;
    text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
}
.nav-tab:hover { background: #334155; color: #e2e8f0; }
.nav-tab.active { background: #3b82f6; color: #fff; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-user { font-size: 13px; color: #94a3b8; }
.nav-btn {
    background: #334155; border: none; color: #94a3b8;
    padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.nav-btn:hover { background: #475569; color: #e2e8f0; }

/* Layout */
.main { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* Section */
.section {
    background: #1e293b; border-radius: 10px; border: 1px solid #334155;
    margin-bottom: 20px; overflow: hidden;
}
.section-header {
    padding: 14px 20px; border-bottom: 1px solid #334155;
    display: flex; align-items: center; justify-content: space-between;
}
.section-header h2 { font-size: 15px; font-weight: 600; }

/* Stats */
.stats {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px;
}
.stat-card {
    background: #1e293b; border-radius: 10px; padding: 14px 16px;
    border: 1px solid #334155; display: flex; flex-direction: column; gap: 2px;
}
.stat-card .label {
    font-size: 11px; color: #64748b; text-transform: uppercase;
    letter-spacing: 1px; font-weight: 600;
}
.stat-card .value-row { display: flex; align-items: baseline; gap: 4px; margin-top: 2px; }
.stat-card .big { font-size: 26px; font-weight: 700; color: #f1f5f9; }
.stat-card .small { font-size: 13px; color: #64748b; }
.stat-card .status-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.live-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #22c55e;
    display: inline-block; animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Agent cards */
.agent-list { display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto; }
.agent-card {
    flex: 0 0 auto; min-width: 120px; background: #0f172a;
    border: 1px solid #334155; border-radius: 8px; padding: 10px 14px;
    display: flex; align-items: center; gap: 10px;
    cursor: pointer; transition: all 0.15s;
}
.agent-card:hover { border-color: #3b82f6; background: #1a2332; }
.agent-card.active { border-color: #3b82f6; background: #1a2332; }
.agent-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; border: 2px solid #475569;
    background: #ffffff;
}
.agent-avatar.online { border-color: #22c55e; }
.agent-avatar.offline { border-color: #475569; }
.agent-info { text-align: left; }
.agent-name { font-size: 13px; font-weight: 600; color: #f1f5f9; }
.agent-id { font-size: 11px; color: #64748b; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 8px; font-size: 10px; font-weight: 700; }
.badge-level { background: #1e3a5f; color: #60a5fa; }
.badge-online { background: #064e3b; color: #34d399; font-size: 11px; }
.badge-offline { background: #451a03; color: #fbbf24; font-size: 11px; }

/* Group cards */
.group-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; padding: 20px; }
.group-card {
    background: #0f172a; border: 1px solid #334155; border-radius: 10px;
    padding: 16px; display: flex; flex-direction: column; gap: 8px;
    cursor: pointer; transition: all 0.15s;
}
.group-card:hover { border-color: #3b82f6; background: #1a2332; }
.group-card .group-icon {
    width: 40px; height: 40px; border-radius: 10px; background: #1e3a5f;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.group-card .group-name { font-size: 14px; font-weight: 600; color: #f1f5f9; }
.group-card .group-meta { font-size: 12px; color: #64748b; }
.badge-visibility { font-size: 10px; padding: 1px 6px; border-radius: 8px; font-weight: 700; }
.badge-public { background: #064e3b; color: #34d399; }
.badge-private { background: #3b0764; color: #c084fc; }
.badge-owner { background: #92400e; color: #fcd34d; }

/* Talk bubbles */
.talk-messages {
    max-height: calc(100vh - 340px); min-height: 200px; overflow-y: auto; padding: 16px 20px;
    display: flex; flex-direction: column; gap: 8px;
}
.talk-bubble {
    max-width: 80%; padding: 10px 14px; border-radius: 12px;
    font-size: 14px; line-height: 1.5; word-break: break-word;
}
.talk-bubble.sent { align-self: flex-end; background: #1e3a5f; color: #93c5fd; border-bottom-right-radius: 4px; }
.talk-bubble.received { align-self: flex-start; background: #334155; color: #e2e8f0; border-bottom-left-radius: 4px; }
.talk-bubble .talk-meta { font-size: 11px; color: #64748b; margin-top: 4px; }
.talk-input { border-top: 1px solid #334155; padding: 12px 16px; }
.talk-compose { display: flex; gap: 8px; align-items: flex-end; }
.talk-compose textarea {
    flex: 1; background: #0f172a; border: 2px solid #334155; border-radius: 8px;
    color: #e2e8f0; padding: 10px 12px; font-size: 14px; resize: none; outline: none; font-family: inherit;
}
.talk-compose textarea:focus { border-color: #3b82f6; }
.btn-send {
    background: #3b82f6; color: #fff; border: none; padding: 10px 20px;
    border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-send:hover { background: #2563eb; }
.btn-send:disabled { background: #1e40af; opacity: 0.6; cursor: not-allowed; }
.talk-empty { text-align: center; color: #475569; padding: 30px; font-size: 14px; margin: auto; }
.talk-load-more { text-align: center; padding: 8px; }
.talk-load-more button {
    background: none; border: 1px solid #334155; color: #64748b;
    padding: 4px 16px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.talk-load-more button:hover { border-color: #3b82f6; color: #94a3b8; }

/* Messages */
.msg-toolbar {
    padding: 10px 20px; border-bottom: 1px solid #334155;
    display: flex; gap: 8px; align-items: center; flex-wrap: nowrap;
    overflow-x: auto;
}
.msg-filter {
    background: #0f172a; border: 1px solid #334155; color: #e2e8f0;
    padding: 6px 10px; border-radius: 6px; font-size: 13px; outline: none;
    flex-shrink: 0;
}
.msg-filter:focus { border-color: #3b82f6; }
.msg-filter option { background: #1e293b; }
.msg-list { max-height: calc(100vh - 280px); min-height: 200px; overflow-y: auto; }
.msg-group { border: 1px solid #2a2a4a; border-radius: 8px; margin: 8px 12px; overflow: hidden; }
.msg-group-header {
    display: flex; align-items: center; gap: 8px; padding: 8px 14px;
    background: #1a1a2e; cursor: pointer; font-size: 12px;
}
.msg-group-header:hover { background: rgba(139, 92, 246, 0.08); }
.msg-group-header .action-text { font-weight: 700; color: #e2e8f0; }
.msg-group-header .meta-text { color: #64748b; font-size: 12px; }
.msg-group-header .toggle-icon { color: #64748b; font-size: 10px; transition: transform 0.2s; }
.msg-group-header .toggle-icon.collapsed { transform: rotate(-90deg); }
.msg-group-body { border-top: 1px solid #2a2a4a; }
.msg-group-body.collapsed { display: none; }
.msg-item { padding: 10px 20px 12px; transition: background 0.1s; }
.msg-item:hover { background: #1a2332; }
.msg-row1 { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.msg-type { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.msg-type-task { background: #1e3a5f; color: #60a5fa; }
.msg-type-response { background: #064e3b; color: #34d399; }
.msg-type-reply { background: #451a03; color: #fbbf24; }
.msg-type-notice { background: #3b0764; color: #c084fc; }
.msg-type-alert { background: #7f1d1d; color: #fca5a5; }
.msg-type-talk { background: #134e4a; color: #5eead4; }
.msg-action-text { font-size: 13px; font-weight: 600; color: #94a3b8; }
.msg-time { font-size: 12px; color: #475569; margin-left: auto; }
.msg-row2 { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 12px; color: #64748b; }
.msg-row2 .flow { color: #94a3b8; }
.msg-row2 .mid { color: #475569; margin-left: auto; }
.msg-body { font-size: 13px; color: #94a3b8; line-height: 1.5; max-height: 80px; overflow: hidden; word-break: break-all; }
.msg-empty { padding: 40px; text-align: center; color: #475569; font-size: 14px; }
.pagination {
    padding: 10px 20px; display: flex; align-items: center;
    justify-content: space-between; border-top: 1px solid #334155; font-size: 13px; color: #64748b;
}
.pagination button {
    background: #334155; border: none; color: #94a3b8;
    padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.pagination button:hover { background: #475569; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Group Detail */
.group-detail { padding: 20px; }
.group-detail-header {
    display: flex; align-items: center; gap: 16px; margin-bottom: 20px;
    padding-bottom: 16px; border-bottom: 1px solid #334155;
}
.group-detail-header .icon {
    width: 56px; height: 56px; border-radius: 14px; background: #1e3a5f;
    display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.group-detail-header .info { flex: 1; }
.group-detail-header .gname { font-size: 20px; font-weight: 700; color: #f1f5f9; }
.group-detail-header .gdesc { font-size: 13px; color: #94a3b8; margin-top: 2px; }
.group-detail-header .gmeta { font-size: 12px; color: #64748b; margin-top: 4px; display: flex; gap: 12px; }
.group-detail .back-btn {
    background: #334155; border: none; color: #94a3b8;
    padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; margin-bottom: 16px;
}
.group-detail .back-btn:hover { background: #475569; color: #e2e8f0; }
.group-member-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 20px; }
.group-member-item {
    background: #0f172a; border: 1px solid #334155; border-radius: 8px;
    padding: 10px; display: flex; align-items: center; gap: 8px;
    min-width: 0;
}
.group-member-item .avatar, .group-member-item .agent-avatar { position: relative; flex-shrink: 0; }
.group-member-item .avatar .owner-badge, .group-member-item .agent-avatar .owner-badge {
    position: absolute; bottom: -2px; right: -2px;
    font-size: 10px; line-height: 1;
}
.group-member-item .mname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-member-item .mrole { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-member-item .avatar, .group-member-item .agent-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; border: 2px solid #475569;
}
.group-member-item .avatar.online, .group-member-item .agent-avatar.online { border-color: #22c55e; }
.group-member-item .minfo { flex: 1; }
.group-member-item .mname { font-size: 13px; font-weight: 600; color: #f1f5f9; }
.group-member-item .mrole { font-size: 11px; color: #64748b; }
.group-rules-box {
    background: #0f172a; border: 1px solid #334155; border-radius: 8px;
    padding: 14px; margin-bottom: 16px; font-size: 13px;
    color: #94a3b8; line-height: 1.6; white-space: pre-wrap;
}

/* Mobile bottom nav */
.nav-mobile {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #1e293b; border-top: 1px solid #334155; z-index: 100; padding: 6px 0;
}
.nav-mobile-inner { display: flex; justify-content: space-around; }
.nav-mobile-tab {
    background: none; border: none; color: #64748b; font-size: 11px; font-weight: 600;
    cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 4px 12px; text-decoration: none;
}
.nav-mobile-tab .tab-icon { font-size: 20px; }
.nav-mobile-tab.active { color: #3b82f6; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

/* Responsive */
@media (max-width: 768px) {
    .nav { padding: 12px 16px; }
    .nav-tabs { display: none; }
    .nav-mobile { display: block; }
    .main { padding: 12px; padding-bottom: 72px; }
    .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 10px 12px; }
    .stat-card .big { font-size: 22px; }
    .agent-list { padding: 8px 10px; gap: 6px; }
    .agent-card { min-width: 110px; padding: 8px 10px; }
    .talk-messages { max-height: calc(100vh - 360px); min-height: 200px; }
}

/* Nav notification dot */
.nav-tab, .nav-mobile-tab { position: relative; }
.nav-dot {
    position: absolute; top: 6px; right: 4px;
    width: 8px; height: 8px; border-radius: 50%;
    background: #ef4444; border: 2px solid #1e293b;
    pointer-events: none;
}
.nav-mobile-tab .nav-dot {
    top: 2px; right: 8px;
}
/* Card notification dot */
.card-dot {
    position: absolute; top: 4px; right: 4px;
    width: 10px; height: 10px; border-radius: 50%;
    background: #ef4444; border: 2px solid #0f172a;
    pointer-events: none;
}
