/* ============================================================
   TriggerLab CRM — Design System (Supabase Edition)
   ============================================================ */
:root {
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-hover: #1a1a2e;
    --bg-input: #16162a;
    --text: #e4e4f0;
    --text-muted: #8888a8;
    --text-dim: #555570;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-glow: rgba(99, 102, 241, .15);
    --accent: #e94560;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #2a2a3e;
    --border-light: #333350;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 20px rgba(0, 0, 0, .4);
    --transition: .2s ease;
    --sidebar-w: 220px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: .75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

h4 {
    font-size: .9rem;
    font-weight: 600;
    margin-bottom: .5rem;
}

.subtle {
    color: var(--text-muted);
    font-size: .85rem;
}

.empty {
    color: var(--text-dim);
    font-size: .9rem;
}

.tag {
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .75rem;
    color: var(--primary);
}

.badge {
    background: var(--accent);
    color: #fff;
    font-size: .65rem;
    padding: 1px 6px;
    border-radius: 999px;
    margin-left: .5rem;
}

.clickable {
    cursor: pointer;
}

.clickable:hover {
    background: var(--bg-hover);
}

/* ============ LOGIN PAGE ============ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #0f0f1a 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo-icon {
    font-size: 3rem;
    margin-bottom: .5rem;
    animation: pulse-glow 2s ease-in-out infinite;
}

.login-logo h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-logo p {
    color: var(--text-muted);
    font-size: .9rem;
    letter-spacing: .2em;
    text-transform: uppercase;
}

.login-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}

.login-error {
    color: var(--accent);
    font-size: .85rem;
    margin-top: .75rem;
    text-align: center;
    min-height: 1.2em;
}

@keyframes pulse-glow {

    0%,
    100% {
        filter: drop-shadow(0 0 8px rgba(99, 102, 241, .4));
    }

    50% {
        filter: drop-shadow(0 0 20px rgba(233, 69, 96, .6));
    }
}

/* ============ APP LAYOUT ============ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-items {
    list-style: none;
    flex: 1;
    padding: .75rem 0;
    overflow-y: auto;
}

.nav-item {
    padding: .7rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition);
    border-left: 3px solid transparent;
    font-size: .9rem;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.nav-item.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: var(--primary-glow);
    font-weight: 600;
}

.nav-icon {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: .85rem;
    padding: .5rem;
    width: 100%;
    text-align: left;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.btn-logout:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

/* ============ MAIN CONTENT ============ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 1.5rem 2rem;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

/* ============ BUTTONS ============ */
.btn {
    padding: .5rem 1rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: .85rem;
    transition: all var(--transition);
    font-family: inherit;
}

.btn:hover {
    border-color: var(--text-muted);
    background: var(--bg-hover);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: .3rem .6rem;
    font-size: .8rem;
}

.btn-block {
    width: 100%;
    padding: .7rem;
    font-size: .95rem;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
    border-radius: 4px;
}

.btn-icon:hover {
    color: var(--accent);
    background: var(--bg-hover);
}

/* ============ FORMS ============ */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: .8rem;
    color: var(--text-muted);
    margin-bottom: .3rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .03em;
}

input,
select,
textarea {
    width: 100%;
    padding: .55rem .75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: inherit;
    transition: border-color var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem 1rem;
}

.search-input {
    max-width: 250px;
}

.select-input {
    max-width: 200px;
}

.form-actions {
    display: flex;
    gap: .5rem;
    margin-top: 1rem;
}

/* ============ TABS ============ */
.tab {
    padding: .5rem 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: .85rem;
    font-family: inherit;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.opp-tabs,
.settings-tabs,
.cc-tabs,
.detail-tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    padding-bottom: 0;
}

/* ============ TABLES ============ */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: .6rem .75rem;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

td {
    padding: .7rem .75rem;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}

tr:hover {
    background: var(--bg-hover);
}

/* ============ STATS ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card.highlight {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--bg-card), var(--primary-glow));
}

.stat-card.won {
    border-color: var(--success);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
}

.stat-label {
    font-size: .75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-top: .25rem;
}

/* ============ PANELS ============ */
.dashboard-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.list-item {
    padding: .5rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: .9rem;
}

.list-item:hover {
    color: var(--primary);
}

.event-type-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: .5rem;
}

.event-type-dot.call {
    background: var(--primary);
}

.event-type-dot.meeting {
    background: var(--success);
}

.event-type-dot.follow_up {
    background: var(--warning);
}

.event-type-dot.demo {
    background: var(--accent);
}

/* ============ CONVERSATIONS ============ */
.conversations-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - 5rem);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.convo-list {
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.convo-list-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.convo-item {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}

.convo-item:hover,
.convo-item.active {
    background: var(--bg-hover);
}

.convo-item-name {
    font-weight: 600;
    font-size: .9rem;
    display: flex;
    justify-content: space-between;
}

.convo-item-preview {
    font-size: .8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.convo-item-time {
    font-size: .7rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.convo-thread {
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.convo-thread-header {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.message {
    display: flex;
}

.message.outbound {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 70%;
    padding: .6rem 1rem;
    border-radius: var(--radius);
    font-size: .9rem;
}

.message.inbound .message-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.message.outbound .message-bubble {
    background: var(--primary);
    color: #fff;
}

.message-channel {
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    opacity: .6;
    display: block;
    margin-bottom: 2px;
}

.message-subject {
    font-weight: 600;
    font-size: .85rem;
    margin-bottom: 4px;
}

.message-bubble small {
    display: block;
    font-size: .7rem;
    opacity: .5;
    margin-top: 4px;
}

.message-composer {
    border-top: 1px solid var(--border);
    padding: .75rem 1rem;
    background: var(--bg-card);
}

.composer-channel {
    display: flex;
    gap: 1rem;
    margin-bottom: .5rem;
    font-size: .85rem;
}

.composer-channel label {
    display: flex;
    align-items: center;
    gap: .3rem;
    cursor: pointer;
    color: var(--text-muted);
}

.composer-input {
    display: flex;
    gap: .5rem;
}

.composer-input textarea {
    flex: 1;
    resize: none;
}

#email-subject-row {
    margin-bottom: .5rem;
}

/* ============ KANBAN ============ */
.kanban-board {
    display: flex;
    gap: .75rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.kanban-column {
    min-width: 220px;
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem;
}

.kanban-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .75rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
    font-weight: 600;
}

.kanban-count {
    font-size: .75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.kanban-cards {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.kanban-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .6rem .75rem;
    cursor: pointer;
    transition: all var(--transition);
}

.kanban-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.kanban-card-title {
    font-weight: 600;
    font-size: .85rem;
}

.kanban-card-contact {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.kanban-card-value {
    font-size: .8rem;
    color: var(--success);
    font-weight: 600;
    margin-top: 4px;
}

/* ============ CALENDAR ============ */
.calendar-month-label {
    font-size: 1.1rem;
    font-weight: 600;
    min-width: 200px;
    text-align: center;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.cal-header {
    background: var(--bg-card);
    padding: .5rem;
    text-align: center;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.cal-day {
    background: var(--bg);
    padding: .5rem;
    min-height: 80px;
    font-size: .8rem;
}

.cal-day.empty {
    background: var(--bg-card);
    opacity: .3;
}

.cal-day.today {
    background: var(--primary-glow);
}

.cal-day-num {
    font-weight: 600;
    font-size: .85rem;
}

.cal-event {
    margin-top: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: .7rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-event.call {
    background: rgba(99, 102, 241, .2);
    color: var(--primary);
}

.cal-event.meeting {
    background: rgba(34, 197, 94, .2);
    color: var(--success);
}

.cal-event.follow_up {
    background: rgba(245, 158, 11, .2);
    color: var(--warning);
}

.cal-event.demo {
    background: rgba(233, 69, 96, .2);
    color: var(--accent);
}

.cal-event.other {
    background: var(--bg-hover);
    color: var(--text-muted);
}

/* ============ SETTINGS ============ */
.provider-grid {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.provider-btn {
    padding: .5rem 1.25rem;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: .85rem;
    transition: all var(--transition);
}

.provider-btn:hover {
    border-color: var(--text-muted);
}

.provider-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-glow);
}

/* ============ MODALS ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .7);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 .5rem;
}

.modal-close:hover {
    color: var(--accent);
}

.modal-body {
    padding: 1.25rem;
}

/* ============ SLIDE PANEL ============ */
.slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    z-index: 150;
    overflow-y: auto;
    box-shadow: -8px 0 30px rgba(0, 0, 0, .4);
    animation: slideIn .2s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

.slide-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.slide-panel-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.slide-panel-body {
    padding: 1.25rem;
}

.contact-quick-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.note-add {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
}

.note-add textarea {
    flex: 1;
}

.note-item {
    padding: .5rem 0;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.note-item .btn-icon {
    position: absolute;
    right: 0;
    top: .5rem;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}

.info-grid p {
    font-size: .9rem;
}

.contact-picker .picker-item {
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}

.contact-picker .picker-item:hover {
    background: var(--bg-hover);
}

/* ============================================================
   COMMAND CENTER — The Agent Dashboard
   ============================================================ */
.cc-live-indicator {
    color: var(--success);
    font-size: .85rem;
    font-weight: 600;
    animation: blink 2s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .4;
    }
}

/* Agent Cards Grid */
.agent-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.agent-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all .25s ease;
    position: relative;
    overflow: hidden;
}

.agent-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--agent-color, var(--border));
    transition: height .3s ease;
}

.agent-card:hover {
    border-color: var(--agent-color, var(--primary));
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, .3);
}

.agent-card:hover::before {
    height: 4px;
}

.agent-card.active {
    border-color: var(--success);
}

.agent-card.down {
    border-color: var(--danger);
    background: linear-gradient(135deg, var(--bg-card), rgba(239, 68, 68, .05));
}

.agent-card-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
}

.agent-emoji {
    font-size: 1.5rem;
}

.agent-name {
    font-weight: 700;
    font-size: .9rem;
    letter-spacing: .05em;
    flex: 1;
}

.agent-status-dot {
    font-size: .9rem;
}

.agent-role {
    font-size: .75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-bottom: .5rem;
}

.agent-task {
    font-size: .85rem;
    color: var(--text);
    min-height: 2.5em;
    margin-bottom: .5rem;
}

.agent-meta {
    font-size: .75rem;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.agent-err-badge {
    background: rgba(245, 158, 11, .15);
    color: var(--warning);
    padding: 1px 6px;
    border-radius: 999px;
    font-size: .7rem;
}

/* Activity Feed */
.cc-activity-feed {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.feed-item {
    display: flex;
    gap: .75rem;
    padding: .75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.feed-item:hover {
    border-color: var(--border-light);
}

.feed-item.error {
    border-left: 3px solid var(--warning);
}

.feed-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.feed-content {
    flex: 1;
    min-width: 0;
}

.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.feed-header strong {
    font-size: .8rem;
    letter-spacing: .05em;
}

.feed-time {
    font-size: .7rem;
    color: var(--text-dim);
}

.feed-content p {
    font-size: .85rem;
    margin: 0;
}

.feed-detail {
    color: var(--text-muted);
    font-size: .8rem;
    margin-top: 4px;
}

/* Errors List */
.cc-errors-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.error-item {
    padding: .75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.error-item.critical {
    border-left: 3px solid var(--danger);
    background: linear-gradient(90deg, rgba(239, 68, 68, .05), transparent);
}

.error-item.warning {
    border-left: 3px solid var(--warning);
}

.error-item.info {
    border-left: 3px solid var(--primary);
}

.error-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .25rem;
    flex-wrap: wrap;
}

.error-sev {
    font-size: .8rem;
}

.error-type {
    font-size: .75rem;
    background: var(--bg-hover);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--text-muted);
}

.error-item p {
    font-size: .85rem;
    margin: .25rem 0 .5rem;
}

/* Missions List */
.cc-missions-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.mission-item {
    padding: .75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.mission-item.completed {
    opacity: .6;
}

.mission-item.cancelled {
    opacity: .4;
}

.mission-item.active {
    border-left: 3px solid var(--success);
}

.mission-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.mission-status {
    font-size: .9rem;
}

.mission-agent {
    font-size: .75rem;
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 999px;
    color: var(--text-muted);
    margin-left: auto;
}

.mission-desc {
    font-size: .85rem;
    color: var(--text-muted);
    margin: .5rem 0;
}

.mission-actions {
    display: flex;
    gap: .5rem;
    margin-top: .5rem;
}

/* Agent Detail Panel */
.agent-detail-section {
    margin-bottom: 1.5rem;
}

.report-item {
    padding: .6rem 0;
    border-bottom: 1px solid var(--border);
}

.report-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .25rem;
}

.report-type.badge {
    font-size: .65rem;
}

.error-item-sm {
    padding: .4rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
}

.error-item-sm.critical {
    color: var(--danger);
}

.error-item-sm .resolved {
    color: var(--success);
    font-size: .75rem;
    margin-left: .5rem;
}

.hb-item {
    padding: .3rem 0;
    font-size: .85rem;
    display: flex;
    gap: .5rem;
    align-items: center;
}

.hb-status {
    font-size: .7rem;
    padding: 1px 6px;
    border-radius: 4px;
}

.hb-status.active {
    background: rgba(34, 197, 94, .15);
    color: var(--success);
}

.hb-status.idle {
    background: var(--bg-hover);
    color: var(--text-muted);
}

.hb-status.error {
    background: rgba(239, 68, 68, .15);
    color: var(--danger);
}

/* ============ CC PANEL CONTAINER ============ */
.cc-panel {
    max-height: 500px;
    overflow-y: auto;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .nav-label,
    .logo-text,
    .sidebar-footer {
        display: none;
    }

    .main-content {
        margin-left: 60px;
        padding: 1rem;
    }

    .conversations-layout {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-panels {
        grid-template-columns: 1fr;
    }

    .agent-cards-grid {
        grid-template-columns: 1fr 1fr;
    }

    .slide-panel {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============ AGENT CHAT PANEL ============ */
.agent-chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(6px);
    z-index: 300;
    display: flex;
    justify-content: flex-end;
}

.agent-chat-panel {
    width: 480px;
    max-width: 100%;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    animation: slideIn .25s ease;
}

.agent-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--bg-card), var(--bg-hover));
}

.agent-chat-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.1rem;
    font-weight: 700;
}

.agent-chat-role {
    font-size: .75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .1em;
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 999px;
}

.agent-chat-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0 .5rem;
    line-height: 1;
    transition: color var(--transition);
}

.agent-chat-close:hover {
    color: var(--accent);
}

.agent-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.chat-msg {
    display: flex;
    max-width: 85%;
}

.chat-msg.founder {
    align-self: flex-end;
}

.chat-msg.agent {
    align-self: flex-start;
}

.chat-msg-bubble {
    padding: .6rem 1rem;
    border-radius: 12px;
    font-size: .9rem;
    line-height: 1.5;
    position: relative;
}

.chat-msg.founder .chat-msg-bubble {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.agent .chat-msg-bubble {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-msg-time {
    display: block;
    font-size: .65rem;
    opacity: .5;
    margin-top: 4px;
}

.chat-msg-sender {
    display: block;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 2px;
    opacity: .7;
}

.agent-chat-composer {
    display: flex;
    gap: .5rem;
    padding: .75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.agent-chat-composer textarea {
    flex: 1;
    resize: none;
    background: var(--bg-card);
}

.agent-chat-composer .btn {
    align-self: flex-end;
}

/* Chat unread badge on agent card */
.agent-chat-badge {
    position: absolute;
    top: .5rem;
    right: .5rem;
    background: var(--accent);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
    animation: pop .3s ease;
}

@keyframes pop {
    0% {
        transform: scale(0);
    }

    70% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* ============ TOAST NOTIFICATIONS ============ */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .7rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
    font-size: .85rem;
    pointer-events: auto;
    animation: toastIn .3s ease;
    min-width: 250px;
    max-width: 400px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.warning {
    border-left: 3px solid var(--warning);
}

.toast.info {
    border-left: 3px solid var(--primary);
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast-text {
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text);
}

@keyframes toastIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============ LOADING SPINNER ============ */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

.spinner-lg {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
    color: var(--text-muted);
    font-size: .85rem;
}