/* =============================================
   AGREEGATE SPA — Component Styles
   ============================================= */

/* ── Auth Pages ────────────────────────────── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(19, 26, 46, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 44px 40px;
    position: relative;
    z-index: 1;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.03),
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 80px rgba(13, 148, 136, 0.06);
    backdrop-filter: blur(20px);
}

.auth-brand {
    text-align: center;
    margin-bottom: 36px;
}
.auth-brand-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--ag-teal), var(--ag-teal-light));
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    margin-bottom: 16px;
    box-shadow: 0 4px 20px var(--ag-teal-glow);
}
.auth-brand h1 {
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #fff;
}
.auth-brand p {
    color: var(--ag-text-secondary);
    font-size: 0.9rem;
    margin-top: 6px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 24px 0;
    color: var(--ag-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.auth-footer {
    text-align: center;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.8125rem;
    color: var(--ag-text-muted);
}
.auth-footer a {
    color: var(--ag-teal-light);
    font-weight: 600;
}
.auth-footer a:hover {
    text-decoration: underline;
}

.auth-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--ag-radius-sm);
    padding: 10px 14px;
    color: var(--ag-error);
    font-size: 0.8125rem;
    margin-bottom: 16px;
}

/* Google button */
.ag-btn-google {
    background: #fff;
    color: #1f1f1f;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.9375rem;
    padding: 12px 20px;
    border-radius: var(--ag-radius-sm);
    transition: all var(--ag-transition);
}
.ag-btn-google:hover:not(:disabled) {
    background: #f0f0f0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}
.ag-btn-google svg,
.ag-btn-google img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ── App Shell ─────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
    width: var(--ag-sidebar-width);
    background: var(--ag-bg-raised);
    border-right: 1px solid var(--ag-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transition: width var(--ag-transition-slow);
}
.app-sidebar.collapsed {
    width: var(--ag-sidebar-collapsed);
}

.sidebar-brand {
    height: var(--ag-header-height);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    border-bottom: 1px solid var(--ag-border);
    flex-shrink: 0;
}
.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background: var(--ag-teal);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
}
.sidebar-brand-text {
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ag-text);
}
.app-sidebar.collapsed .sidebar-brand-text { display: none; }

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

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--ag-radius-sm);
    color: var(--ag-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--ag-transition);
    cursor: pointer;
}
.sidebar-link:hover {
    background: var(--ag-bg-card);
    color: var(--ag-text);
}
.sidebar-link.active {
    background: var(--ag-teal-subtle);
    color: var(--ag-teal-light);
}
.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: 0.9375rem;
    flex-shrink: 0;
}
.app-sidebar.collapsed .sidebar-link span { display: none; }
.app-sidebar.collapsed .sidebar-link { justify-content: center; padding: 10px; }

.sidebar-section-label {
    padding: 16px 12px 6px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ag-text-muted);
}
.app-sidebar.collapsed .sidebar-section-label { display: none; }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--ag-border);
}
.sidebar-collapse-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: var(--ag-radius-sm);
    color: var(--ag-text-muted);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all var(--ag-transition);
}
.sidebar-collapse-btn:hover { background: var(--ag-bg-card); color: var(--ag-text-secondary); }
.app-sidebar.collapsed .sidebar-collapse-btn span { display: none; }

/* Main content area */
.app-main {
    flex: 1;
    margin-left: var(--ag-sidebar-width);
    transition: margin-left var(--ag-transition-slow);
}
.app-sidebar.collapsed ~ .app-main,
.app-main.sidebar-collapsed {
    margin-left: var(--ag-sidebar-collapsed);
}

/* Header */
.app-header {
    height: var(--ag-header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--ag-border);
    background: var(--ag-bg);
    position: sticky;
    top: 0;
    z-index: 40;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Tenant switcher */
.tenant-switcher {
    position: relative;
}
.tenant-switcher-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius-sm);
    color: var(--ag-text);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--ag-transition);
}
.tenant-switcher-btn:hover {
    border-color: var(--ag-border-hover);
    background: var(--ag-bg-card-hover);
}
.tenant-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    min-width: 200px;
    background: var(--ag-bg-raised);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius-sm);
    padding: 4px;
    box-shadow: var(--ag-shadow-lg);
    z-index: 100;
}
.tenant-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--ag-text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all var(--ag-transition);
}
.tenant-dropdown-item:hover { background: var(--ag-bg-card); color: var(--ag-text); }
.tenant-dropdown-item.active { color: var(--ag-teal-light); }

/* User menu */
.user-menu {
    position: relative;
}
.user-avatar-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--ag-border);
    overflow: hidden;
    cursor: pointer;
    transition: border-color var(--ag-transition);
    background: var(--ag-bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ag-text-secondary);
    font-size: 0.875rem;
}
.user-avatar-btn:hover { border-color: var(--ag-teal); }
.user-avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 200px;
    background: var(--ag-bg-raised);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius-sm);
    padding: 4px;
    box-shadow: var(--ag-shadow-lg);
    z-index: 100;
}
.user-dropdown-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--ag-border);
    margin-bottom: 4px;
}
.user-dropdown-header .name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ag-text);
}
.user-dropdown-header .email {
    font-size: 0.75rem;
    color: var(--ag-text-muted);
}
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--ag-text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all var(--ag-transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--ag-font);
}
.user-dropdown-item:hover { background: var(--ag-bg-card); color: var(--ag-text); }

/* ── Page Content ──────────────────────────── */
.page-content {
    padding: 24px;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-title {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ── Dashboard: Thread Zones ───────────────── */
.dashboard-zones {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.zone {
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius);
    overflow: hidden;
}
.zone-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--ag-border);
}
.zone-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 600;
}
.zone-count {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: var(--ag-radius-full);
    background: var(--ag-bg-card);
}
.zone-fire .zone-header { border-bottom-color: rgba(239, 68, 68, 0.3); }
.zone-fire .zone-title { color: var(--ag-fire); }
.zone-fire .zone-count { background: rgba(239, 68, 68, 0.15); color: var(--ag-fire); }

.zone-decision .zone-header { border-bottom-color: rgba(245, 158, 11, 0.3); }
.zone-decision .zone-title { color: var(--ag-decision); }
.zone-decision .zone-count { background: rgba(245, 158, 11, 0.15); color: var(--ag-decision); }

.zone-routine .zone-header { border-bottom-color: rgba(59, 130, 246, 0.3); }
.zone-routine .zone-title { color: var(--ag-routine); }
.zone-routine .zone-count { background: rgba(59, 130, 246, 0.15); color: var(--ag-routine); }

.zone-resolved .zone-header { border-bottom-color: rgba(34, 197, 94, 0.3); }
.zone-resolved .zone-title { color: var(--ag-resolved); }
.zone-resolved .zone-count { background: rgba(34, 197, 94, 0.15); color: var(--ag-resolved); }

.zone-body {
    padding: 8px;
    max-height: 60vh;
    overflow-y: auto;
}
.zone-empty {
    padding: 24px;
    text-align: center;
    color: var(--ag-text-muted);
    font-size: 0.8125rem;
}

/* Thread card */
.thread-card {
    padding: 12px 14px;
    border-radius: var(--ag-radius-sm);
    cursor: pointer;
    transition: all var(--ag-transition);
    border: 1px solid transparent;
}
.thread-card:hover {
    background: var(--ag-bg-card-hover);
    border-color: var(--ag-border);
}
.thread-card.selected {
    background: var(--ag-bg-card-selected);
    border-color: var(--ag-border-focus);
}
.thread-card-title {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.3;
}
.thread-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.6875rem;
    color: var(--ag-text-muted);
}
.thread-card-subject {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--ag-bg-card);
    font-size: 0.6875rem;
    color: var(--ag-text-secondary);
}

/* Thread detail panel */
.thread-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 480px;
    max-width: 100vw;
    height: 100vh;
    background: var(--ag-bg-raised);
    border-left: 1px solid var(--ag-border);
    z-index: 60;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.3);
    transition: transform var(--ag-transition-slow);
}
.thread-detail-panel.hidden {
    transform: translateX(100%);
}

.thread-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--ag-border);
}
.thread-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}
.thread-detail-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--ag-border);
}

/* ── Dashboard Toolbar ─────────────────────── */
.dashboard-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 360px;
}
.search-input-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ag-text-muted);
    font-size: 0.8125rem;
}
.search-input-wrap .ag-input {
    padding-left: 36px;
}

.filter-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.filter-chip {
    padding: 5px 12px;
    border-radius: var(--ag-radius-full);
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    color: var(--ag-text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--ag-transition);
}
.filter-chip:hover { border-color: var(--ag-border-hover); color: var(--ag-text); }
.filter-chip.active {
    background: var(--ag-teal-subtle);
    border-color: var(--ag-border-focus);
    color: var(--ag-teal-light);
}

/* ── Timeline ──────────────────────────────── */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.timeline-item {
    display: flex;
    gap: 12px;
}
.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ag-teal);
    margin-top: 6px;
    flex-shrink: 0;
}
.timeline-dot.note { background: var(--ag-info); }
.timeline-dot.system { background: var(--ag-text-muted); }
.timeline-content {
    flex: 1;
    min-width: 0;
}
.timeline-author {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 2px;
}
.timeline-text {
    font-size: 0.8125rem;
    color: var(--ag-text-secondary);
    line-height: 1.5;
}
.timeline-time {
    font-size: 0.6875rem;
    color: var(--ag-text-muted);
    margin-top: 4px;
}

/* ── Admin ─────────────────────────────────── */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius);
    padding: 16px;
}
.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}
.stat-label {
    font-size: 0.75rem;
    color: var(--ag-text-muted);
    margin-top: 4px;
}

.admin-tenant-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.admin-tenant-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius-sm);
    cursor: pointer;
    transition: all var(--ag-transition);
}
.admin-tenant-row:hover {
    background: var(--ag-bg-card-hover);
    border-color: var(--ag-border-hover);
}
.admin-tenant-row.active {
    background: var(--ag-bg-card-selected);
    border-color: var(--ag-border-focus);
}
.admin-tenant-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.admin-tenant-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--ag-teal-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ag-teal-light);
    font-size: 0.875rem;
}
.admin-tenant-name {
    font-weight: 600;
    font-size: 0.875rem;
}
.admin-tenant-slug {
    font-size: 0.75rem;
    color: var(--ag-text-muted);
}
.admin-tenant-stats {
    display: flex;
    gap: 16px;
    font-size: 0.75rem;
    color: var(--ag-text-secondary);
}

/* Purge controls */
.purge-section {
    margin-top: 24px;
    padding: 20px;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: var(--ag-radius);
}
.purge-title {
    color: var(--ag-error);
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.purge-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.purge-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.1);
    border-radius: var(--ag-radius-sm);
}
.purge-option-label {
    font-size: 0.8125rem;
    font-weight: 500;
}
.purge-option-desc {
    font-size: 0.75rem;
    color: var(--ag-text-muted);
}

/* Confirmation modal */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: var(--ag-bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.confirm-modal {
    background: var(--ag-bg-raised);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius-lg);
    padding: 32px;
    max-width: 440px;
    width: 90%;
    box-shadow: var(--ag-shadow-lg);
}
.confirm-modal h3 {
    margin-bottom: 12px;
}
.confirm-modal p {
    color: var(--ag-text-secondary);
    font-size: 0.875rem;
    margin-bottom: 20px;
    line-height: 1.5;
}
.confirm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 768px) {
    .app-sidebar {
        width: var(--ag-sidebar-collapsed);
    }
    .app-sidebar .sidebar-brand-text,
    .app-sidebar .sidebar-link span,
    .app-sidebar .sidebar-section-label,
    .app-sidebar .sidebar-collapse-btn span {
        display: none;
    }
    .app-sidebar .sidebar-link { justify-content: center; padding: 10px; }
    .app-main { margin-left: var(--ag-sidebar-collapsed); }

    .dashboard-zones {
        grid-template-columns: 1fr;
    }
    .thread-detail-panel {
        width: 100vw;
    }
    .auth-card {
        margin: 16px;
        padding: 28px;
    }
    .deals-kanban {
        flex-direction: column;
    }
    .deals-kanban-col {
        min-width: 100%;
    }
}

/* ── Status Pills ─────────────────────────── */
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    background: var(--ag-bg-subtle);
    color: var(--ag-text-secondary);
}

/* Deal line lifecycle statuses */
.status-pill.sampling { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.status-pill.confirmed,
.status-pill.confirmation-stage { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.status-pill.processing,
.status-pill.in-production { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.status-pill.ready { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.status-pill.shipped,
.status-pill.in-transit { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.status-pill.delivered,
.status-pill.done { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.status-pill.deposit { background: rgba(13, 148, 136, 0.15); color: var(--ag-teal-light, #5eead4); }
.status-pill.to-send-po-to-factory { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.status-pill.arrived-open-payments { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.status-pill.get-new-crd-from-client { background: rgba(236, 72, 153, 0.15); color: #f472b6; }

/* Deal aggregate statuses */
.status-pill.active { background: rgba(13, 148, 136, 0.15); color: var(--ag-teal-light, #5eead4); }
.status-pill.pending { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.status-pill.completed,
.status-pill.closed { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.status-pill.cancelled { background: rgba(239, 68, 68, 0.15); color: #f87171; }

/* ── Deals: Toolbar ───────────────────────── */
.deals-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* ── Deals: Kanban Board ──────────────────── */
.deals-kanban {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    min-height: 200px;
}
.deals-kanban-col {
    min-width: 240px;
    max-width: 300px;
    flex: 1 0 240px;
    display: flex;
    flex-direction: column;
}
.deals-kanban-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
}
.deals-kanban-count {
    font-size: 12px;
    color: var(--ag-text-muted);
    font-weight: 600;
    background: var(--ag-bg-subtle);
    padding: 2px 8px;
    border-radius: 10px;
}
.deals-kanban-col-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.deals-kanban-empty {
    text-align: center;
    padding: 24px 8px;
    font-size: 12px;
    color: var(--ag-text-muted);
    opacity: 0.6;
}

/* ── Deals: Card ──────────────────────────── */
.deal-card {
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.deal-card:hover {
    border-color: var(--ag-teal);
    box-shadow: 0 2px 12px rgba(13, 148, 136, 0.12);
    transform: translateY(-1px);
}
.deal-card.selected {
    border-color: var(--ag-teal);
    box-shadow: 0 0 0 2px var(--ag-teal-glow);
}
.deal-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.deal-card-ref {
    font-weight: 600;
    font-size: 13px;
    color: var(--ag-text-primary);
}
.deal-card-product {
    font-size: 12px;
    color: var(--ag-text-secondary);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.deal-card-parties {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
}
.deal-card-party {
    font-size: 11px;
    color: var(--ag-text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.deal-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
}
.deal-card-metric {
    color: var(--ag-text-muted);
}
.deal-card-value {
    color: var(--ag-teal);
    font-weight: 600;
}

/* ── Deals: Grid Table ────────────────────── */
.deals-grid-wrap {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid var(--ag-border);
}
.deals-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.deals-grid-th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ag-text-muted);
    background: var(--ag-bg-subtle);
    border-bottom: 1px solid var(--ag-border);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.deals-grid-th:hover {
    color: var(--ag-text-primary);
}
.deals-grid-th .sort-icon {
    margin-left: 4px;
    font-size: 10px;
    opacity: 0.5;
}
.deals-grid-row {
    border-bottom: 1px solid var(--ag-border);
    transition: background 0.1s;
}
.deals-grid-row:hover {
    background: rgba(13, 148, 136, 0.04);
}
.deals-grid-row td {
    padding: 10px 14px;
    color: var(--ag-text-secondary);
    white-space: nowrap;
}
.deals-grid-row td.col-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.deals-grid-th.col-numeric {
    text-align: right;
}
.deals-grid-edit {
    width: 100%;
    min-width: 60px;
}

/* ── Deals: Button Group ──────────────────── */
.ag-btn-group {
    display: inline-flex;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--ag-border);
}
.ag-btn-group .ag-btn {
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--ag-border);
}
.ag-btn-group .ag-btn:last-child {
    border-right: none;
}

/* ── Deal Detail Page ─────────────────────── */
.deal-detail-page {
    max-width: 1000px;
}
.deal-detail-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.deal-detail-title {
    font-size: 1.25rem;
    margin: 0;
}
.deal-detail-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--ag-border);
    padding-bottom: 0;
}
.deal-detail-tab {
    padding: 8px 16px;
    font-size: 13px;
    color: var(--ag-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}
.deal-detail-tab:hover {
    color: var(--ag-text-primary);
}
.deal-detail-tab.active {
    color: var(--ag-teal);
    border-bottom-color: var(--ag-teal);
}
.deal-detail-section {
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: 12px;
    padding: 20px 24px;
}

/* ── Deal Fields Grid ─────────────────────── */
.deal-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.deal-field-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ag-text-muted);
    margin-bottom: 4px;
}
.deal-field-value {
    font-size: 14px;
    color: var(--ag-text-primary);
}
.deal-field-highlight {
    color: var(--ag-teal);
    font-weight: 600;
}
.deal-notes {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--ag-border);
}
.deal-notes p {
    font-size: 13px;
    color: var(--ag-text-secondary);
    line-height: 1.5;
}
.deal-section-title {
    font-size: 15px;
    margin: 0 0 12px 0;
    color: var(--ag-text-primary);
}
.deal-subsection-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ag-text-muted);
    margin: 16px 0 8px 0;
}

/* ── Deal Timeline / Milestones ───────────── */
.deal-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
    padding-left: 24px;
}
.deal-milestone {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    position: relative;
}
.deal-milestone::before {
    content: '';
    position: absolute;
    left: -18px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--ag-border);
}
.deal-milestone:last-child::before {
    bottom: 50%;
}
.deal-milestone-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--ag-border);
    border: 2px solid var(--ag-bg-card);
    position: absolute;
    left: -23px;
    top: 16px;
    z-index: 1;
}
.deal-milestone.completed .deal-milestone-dot {
    background: var(--ag-success, #22c55e);
}
.deal-milestone.late .deal-milestone-dot {
    background: var(--ag-fire, #ef4444);
}
.deal-milestone.scheduled .deal-milestone-dot {
    background: var(--ag-teal);
}
.deal-milestone-body {
    flex: 1;
}
.deal-milestone-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--ag-text-primary);
    margin-bottom: 4px;
}
.deal-milestone-dates {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.deal-milestone-date {
    font-size: 12px;
    color: var(--ag-text-muted);
}
.deal-milestone-date.actual {
    color: var(--ag-success, #22c55e);
    font-weight: 600;
}
.deal-milestone-date.sched {
    color: var(--ag-teal);
}

/* ── Deal Documents ───────────────────────── */
.deal-doc-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.deal-doc-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--ag-bg-subtle);
    border-radius: 3px;
    overflow: hidden;
}
.deal-doc-progress-fill {
    height: 100%;
    background: var(--ag-teal);
    border-radius: 3px;
    transition: width 0.3s;
}
.deal-doc-group {
    margin-bottom: 16px;
}
.deal-doc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.deal-doc-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ag-text-secondary);
}
.deal-doc-checkbox input[type="checkbox"] {
    accent-color: var(--ag-teal);
}
.deal-doc-name {
    font-size: 13px;
}
.deal-doc-issue {
    font-size: 11px;
    color: var(--ag-fire, #ef4444);
}

/* ── Thread Entity Panels ─────────────────── */
.thread-panel-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--ag-border);
}
.thread-panel-tab {
    padding: 6px 12px;
    font-size: 12px;
    color: var(--ag-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    gap: 4px;
}
.thread-panel-tab:hover { color: var(--ag-text-primary); }
.thread-panel-tab.active {
    color: var(--ag-teal);
    border-bottom-color: var(--ag-teal);
}
.thread-panel-badge {
    background: var(--ag-teal);
    color: white;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
}
.thread-entities {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.thread-entity-group-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ag-text-muted);
    margin-bottom: 6px;
}
.thread-entity-card {
    background: var(--ag-bg-subtle);
    border: 1px solid var(--ag-border);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 4px;
}
.thread-entity-card.incident {
    border-left: 3px solid var(--ag-fire, #ef4444);
}
.thread-entity-card.settlement {
    border-left: 3px solid var(--ag-teal);
}
.thread-entity-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--ag-text-primary);
}
.thread-entity-sublabel {
    font-size: 11px;
    color: var(--ag-text-muted);
    margin-top: 2px;
}

/* ── Deal: Linked Thread Cards ────────────── */
.deal-threads {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.deal-thread-card {
    background: var(--ag-bg-subtle);
    border: 1px solid var(--ag-border);
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.deal-thread-card:hover {
    border-color: var(--ag-teal);
}
.deal-thread-card-header {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}
.deal-thread-card-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--ag-text-primary);
    margin-bottom: 4px;
}
.deal-thread-card-summary {
    font-size: 12px;
    color: var(--ag-text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════════════════
   PARTNERS
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Partner Type Tabs ──────────────────────── */
.partner-type-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--ag-border);
    padding-bottom: 0;
}
.partner-type-tab {
    padding: 8px 14px;
    font-size: 13px;
    color: var(--ag-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.partner-type-tab:hover {
    color: var(--ag-text-primary);
}
.partner-type-tab.active {
    color: var(--ag-teal);
    border-bottom-color: var(--ag-teal);
}
.partner-type-count {
    font-size: 11px;
    background: var(--ag-bg-subtle);
    color: var(--ag-text-muted);
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
}

/* ── Partner Grid ───────────────────────────── */
.partner-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

/* ── Partner Card ───────────────────────────── */
.partner-card {
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.partner-card:hover {
    border-color: var(--ag-teal);
    box-shadow: 0 2px 12px rgba(13, 148, 136, 0.12);
}
.partner-card.selected {
    border-color: var(--ag-teal);
    box-shadow: 0 0 0 2px var(--ag-teal-glow);
}
.partner-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.partner-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    background: var(--ag-bg-subtle);
    color: var(--ag-text-muted);
}
.partner-card-icon.large {
    width: 44px;
    height: 44px;
    font-size: 18px;
}
.partner-card-icon.customer { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.partner-card-icon.supplier { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.partner-card-icon.logistics { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.partner-card-icon.other { background: var(--ag-bg-subtle); color: var(--ag-text-muted); }

.partner-card-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--ag-text-primary);
}
.partner-card-type {
    font-size: 11px;
    color: var(--ag-text-muted);
}
.partner-card-country,
.partner-card-contacts {
    font-size: 12px;
    color: var(--ag-text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

/* ── Partner Detail Panel ───────────────────── */
.partner-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 100;
    display: flex;
    justify-content: flex-end;
}
.partner-detail-panel {
    width: 480px;
    max-width: 100vw;
    height: 100vh;
    background: var(--ag-bg-main);
    border-left: 1px solid var(--ag-border);
    padding: 24px;
    overflow-y: auto;
    animation: slideInRight 0.2s ease;
}
@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
.partner-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.partner-detail-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
}
.partner-stat {
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}
.partner-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--ag-text-primary);
}
.partner-stat-label {
    font-size: 11px;
    color: var(--ag-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 2px;
}
.partner-contact-row {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.partner-contact-name {
    font-size: 13px;
    color: var(--ag-text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}
.partner-contact-details {
    font-size: 12px;
    color: var(--ag-text-muted);
    display: flex;
    gap: 12px;
    padding-left: 22px;
}
.partner-contact-details span {
    display: flex;
    align-items: center;
    gap: 4px;
}
.partner-status-breakdown {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.partner-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   PRODUCTS
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Product Family Group ───────────────────── */
.product-family-group {
    margin-bottom: 20px;
}
.product-family-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ag-text-primary);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--ag-border);
}

/* ── Product Grid ───────────────────────────── */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

/* ── Product Card ───────────────────────────── */
.product-card {
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: 10px;
    padding: 12px 14px;
    transition: border-color 0.15s;
}
.product-card:hover {
    border-color: var(--ag-teal);
}
.product-card-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--ag-text-primary);
    margin-bottom: 6px;
}
.product-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.product-card-lines {
    font-size: 12px;
    color: var(--ag-text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
}

/* ══════════════════════════════════════════════════════════════════════════
   SETTINGS HUB
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Settings Tabs ──────────────────────────── */
.settings-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--ag-border);
}
.settings-tab {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--ag-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.settings-tab:hover { color: var(--ag-text-primary); }
.settings-tab.active {
    color: var(--ag-teal);
    border-bottom-color: var(--ag-teal);
}

/* ── Settings Panel (tab content) ───────────── */
.settings-panel {
    max-width: 720px;
}

/* ── Settings Section ───────────────────────── */
.settings-section {
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}
.settings-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ag-text-primary);
    margin: 0 0 14px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Settings Fields Grid ───────────────────── */
.settings-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.settings-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.settings-field.full-width {
    grid-column: 1 / -1;
}
.settings-field-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--ag-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ── Settings Actions ───────────────────────── */
.settings-actions {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--ag-border);
}

/* ── Toast Messages ─────────────────────────── */
.settings-toast {
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.2s ease;
}
.settings-toast.success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--ag-success);
    border: 1px solid rgba(16, 185, 129, 0.25);
}
.settings-toast.error {
    background: rgba(239, 68, 68, 0.12);
    color: var(--ag-error);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

/* ── Team ───────────────────────────────────── */
.settings-invite-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.settings-team-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.settings-member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.settings-member-row:last-child { border-bottom: none; }
.settings-member-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.settings-member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ag-bg-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 13px;
    color: var(--ag-text-muted);
}
.settings-member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.settings-member-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--ag-text-primary);
}
.settings-member-email {
    font-size: 12px;
    color: var(--ag-text-muted);
}
.settings-member-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Integration Cards ──────────────────────── */
.settings-integration-card {
    background: var(--ag-bg-subtle);
    border: 1px solid var(--ag-border);
    border-radius: 8px;
    padding: 16px;
}
.settings-integration-header {
    display: flex;
    align-items: center;
    gap: 12px;
}
.settings-integration-details {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--ag-border);
}
.settings-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

/* ── Getting Started (onboarding checklist) ── */
.getting-started {
    max-width: 640px;
    margin: 0 auto;
    padding: 40px 20px;
}
.getting-started-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}
.getting-started-icon {
    font-size: 2rem;
    color: var(--ag-teal);
    flex-shrink: 0;
    margin-top: 2px;
}
.getting-started-header h2 {
    font-size: 1.5rem;
    margin: 0 0 4px;
}
.getting-started-header p {
    color: var(--ag-text-muted);
    margin: 0;
    line-height: 1.5;
    font-size: 0.9rem;
}

/* Progress bar */
.onboarding-progress {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}
.onboarding-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--ag-bg-card);
    border-radius: 3px;
    overflow: hidden;
}
.onboarding-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--ag-teal), var(--ag-teal-light));
    border-radius: 3px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.onboarding-progress-text {
    font-size: 0.8125rem;
    color: var(--ag-text-secondary);
    white-space: nowrap;
}

/* Steps list */
.getting-started-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.getting-started-step {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
}
.getting-started-step:hover {
    border-color: var(--ag-teal);
    box-shadow: 0 2px 12px var(--ag-teal-subtle);
}
.getting-started-step.completed {
    opacity: 0.65;
}
.getting-started-step.completed .step-content h3 {
    text-decoration: line-through;
    text-decoration-color: var(--ag-text-muted);
}

/* Step checkmark circle */
.step-check {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--ag-border-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    color: var(--ag-text-secondary);
    transition: all 0.2s;
}
.step-check.done {
    background: var(--ag-teal);
    border-color: var(--ag-teal);
    color: white;
    font-size: 0.75rem;
}

.step-content {
    flex: 1;
    min-width: 0;
}
.step-content h3 {
    font-size: 0.95rem;
    margin: 0 0 4px;
    font-weight: 600;
}
.step-content h3 i {
    margin-right: 6px;
    color: var(--ag-text-muted);
}
.step-content p {
    font-size: 0.82rem;
    color: var(--ag-text-muted);
    margin: 0;
    line-height: 1.5;
}
.step-arrow {
    color: var(--ag-text-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* ── Header Notification Bell ───────────────── */
.header-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: var(--ag-text-secondary);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.header-icon-btn:hover {
    background: var(--ag-hover);
    color: var(--ag-text-primary);
}
.header-notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--ag-danger, #e53e3e);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ── Notifications View ────────────────────── */
.notif-status {
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.notif-status.success {
    background: rgba(56, 178, 172, 0.12);
    color: var(--ag-primary);
}
.notif-status.error {
    background: rgba(229, 62, 62, 0.12);
    color: var(--ag-danger, #e53e3e);
}
.notif-badge-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--ag-primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 6px;
}
.notif-recipient-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.notif-recipient-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ag-text-muted);
    flex-shrink: 0;
    opacity: 0.4;
}
.notif-recipient-status.active {
    background: #48bb78;
    opacity: 1;
}
.notif-triggers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}
.notif-preview {
    margin-top: 16px;
    padding: 12px;
    background: var(--ag-bg-primary, #0d1117);
    border: 1px solid var(--ag-border);
    border-radius: 8px;
}
.notif-preview pre {
    margin: 8px 0 0;
    white-space: pre-wrap;
    font-size: 0.82rem;
    color: var(--ag-text-secondary);
    font-family: inherit;
}
.notif-preview-meta {
    display: flex;
    gap: 16px;
    font-size: 0.82rem;
    color: var(--ag-text-muted);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--ag-border);
}
.notif-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.notif-table th {
    text-align: left;
    padding: 8px 12px;
    color: var(--ag-text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--ag-border);
}
.notif-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--ag-border);
    color: var(--ag-text-secondary);
}
.notif-priority {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.notif-priority.fire { background: rgba(229, 62, 62, 0.15); color: #fc8181; }
.notif-priority.decision { background: rgba(246, 173, 85, 0.15); color: #f6ad55; }
.notif-priority.routine { background: rgba(56, 178, 172, 0.15); color: var(--ag-primary); }

/* ── Onboarding Wizard ────────────────────── */
.wizard-steps-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 32px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}
.wizard-step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--ag-text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}
.wizard-step-indicator.active { color: var(--ag-text); }
.wizard-step-indicator.done { color: var(--ag-teal); }
.wizard-step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--ag-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    transition: all 0.2s;
}
.wizard-step-indicator.active .wizard-step-dot {
    border-color: var(--ag-teal);
    color: var(--ag-teal);
}
.wizard-step-indicator.done .wizard-step-dot {
    background: var(--ag-teal);
    border-color: var(--ag-teal);
    color: white;
    font-size: 0.7rem;
}
.wizard-step-line {
    flex: 1;
    height: 2px;
    background: var(--ag-border);
    margin: 0 8px;
    margin-bottom: 20px;
    transition: background 0.2s;
}
.wizard-step-line.active { background: var(--ag-teal); }

.wizard-panel {
    text-align: center;
    max-width: 520px;
    margin: 0 auto;
    padding: 20px;
}
.wizard-panel-icon {
    font-size: 2.5rem;
    color: var(--ag-teal);
    margin-bottom: 16px;
}
.wizard-panel h2 {
    font-size: 1.375rem;
    margin: 0 0 8px;
}
.wizard-panel p {
    color: var(--ag-text-secondary);
    margin: 0 0 24px;
    line-height: 1.6;
}

.wizard-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--ag-teal), var(--ag-teal-light));
    color: white;
    border-radius: var(--ag-radius-sm);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ag-transition);
}
.wizard-upload-btn:hover:not(.disabled) {
    box-shadow: 0 4px 20px var(--ag-teal-glow);
    transform: translateY(-1px);
}
.wizard-upload-btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.wizard-config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    text-align: left;
    margin: 20px 0;
}
.wizard-config-item {
    padding: 10px 14px;
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius-sm);
}
.wizard-config-label {
    display: block;
    font-size: 0.75rem;
    color: var(--ag-text-muted);
    margin-bottom: 2px;
}
.wizard-config-value {
    font-size: 0.875rem;
    font-weight: 600;
}

/* ── Wizard Review Panel ─────────────────── */
.wizard-review-panel {
    max-width: 780px;
    margin: 0 auto;
    padding: 20px;
}

.wizard-section-card {
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius);
    margin-bottom: 12px;
    overflow: hidden;
}
.wizard-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background var(--ag-transition);
}
.wizard-section-header:hover {
    background: rgba(255,255,255,0.03);
}
.wizard-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.9375rem;
}
.wizard-section-title i {
    color: var(--ag-teal);
    width: 18px;
    text-align: center;
}
.wizard-section-count {
    background: var(--ag-teal);
    color: white;
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}
.wizard-section-body {
    padding: 0 16px 16px;
    border-top: 1px solid var(--ag-border);
}

/* Editable tables inside review sections */
.wizard-edit-table {
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius-sm);
    overflow: hidden;
}
.wizard-edit-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--ag-border);
}
.wizard-edit-row:last-child { border-bottom: none; }
.wizard-edit-header {
    background: var(--ag-bg-raised);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ag-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.wizard-edit-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8125rem;
}
.wizard-edit-cell.flex-05 { flex: 0.5; text-align: center; }
.wizard-edit-cell.flex-1 { flex: 1; }
.wizard-edit-cell.flex-2 { flex: 2; }

.wizard-inline-input,
.wizard-inline-select {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--ag-radius-sm);
    padding: 3px 6px;
    font-size: 0.8125rem;
    color: var(--ag-text);
    font-family: inherit;
    transition: border-color var(--ag-transition);
}
.wizard-inline-input:hover,
.wizard-inline-select:hover {
    border-color: var(--ag-border);
}
.wizard-inline-input:focus,
.wizard-inline-select:focus {
    outline: none;
    border-color: var(--ag-teal);
    background: var(--ag-bg-raised);
}
.wizard-inline-select { cursor: pointer; }
.wizard-inline-select option { background: var(--ag-bg-raised); color: var(--ag-text); }

.wizard-remove-btn {
    background: transparent;
    border: none;
    color: var(--ag-text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--ag-radius-sm);
    font-size: 0.75rem;
    transition: all var(--ag-transition);
}
.wizard-remove-btn:hover {
    color: var(--ag-danger);
    background: rgba(239, 68, 68, 0.1);
}

.wizard-payment-total {
    padding: 6px 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ag-success);
    text-align: right;
}
.wizard-payment-total.wizard-payment-warn {
    color: var(--ag-warning);
}

.wizard-confidence {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 600;
}
.wizard-confidence.conf-high { background: rgba(16,185,129,0.15); color: var(--ag-success); }
.wizard-confidence.conf-medium { background: rgba(245,158,11,0.15); color: var(--ag-warning); }
.wizard-confidence.conf-low { background: rgba(239,68,68,0.15); color: var(--ag-danger); }

/* Import error list */
.wizard-error-list {
    text-align: left;
    max-width: 500px;
    margin: 0 auto;
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius-sm);
    padding: 12px;
}
.wizard-error-item {
    display: flex;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--ag-border);
    font-size: 0.8125rem;
}
.wizard-error-item:last-child { border-bottom: none; }
.wizard-error-row {
    font-weight: 600;
    color: var(--ag-warning);
    white-space: nowrap;
}
.wizard-error-msg {
    color: var(--ag-text-secondary);
}

/* ── Theme Toggle ─────────────────────────── */
.theme-toggle-btn {
    position: relative;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: var(--ag-radius-sm);
    color: var(--ag-text-secondary);
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all var(--ag-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle-btn:hover {
    background: var(--ag-bg-card);
    color: var(--ag-text);
}

/* ── Light Theme Overrides ───────────────── */
:root[data-theme="light"] .auth-card {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.03),
        0 20px 60px rgba(0, 0, 0, 0.1),
        0 0 80px rgba(13, 148, 136, 0.04);
}
:root[data-theme="light"] .auth-brand h1 { color: var(--ag-text); }
:root[data-theme="light"] .auth-divider::before,
:root[data-theme="light"] .auth-divider::after { background: var(--ag-border); }
:root[data-theme="light"] .auth-footer { border-top-color: var(--ag-border); }
:root[data-theme="light"] .ag-btn-google {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.15);
}
:root[data-theme="light"] .ag-btn-google:hover:not(:disabled) {
    background: #f8f8f8;
}
:root[data-theme="light"] .ag-bg-orb { opacity: 0.08; }
:root[data-theme="light"] .ag-bg-orb-2 { opacity: 0.06; }
:root[data-theme="light"] #app ::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.12); }
:root[data-theme="light"] #app ::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.2); }

/* Status pills — darker text for light backgrounds */
:root[data-theme="light"] .status-pill.sampling,
:root[data-theme="light"] .status-pill.confirmation-stage { color: #6366f1; }
:root[data-theme="light"] .status-pill.in-production { color: #9333ea; }
:root[data-theme="light"] .status-pill.ready,
:root[data-theme="light"] .status-pill.done,
:root[data-theme="light"] .status-pill.closed { color: #16a34a; }
:root[data-theme="light"] .status-pill.in-transit { color: #2563eb; }
:root[data-theme="light"] .status-pill.to-send-po-to-factory,
:root[data-theme="light"] .status-pill.arrived-open-payments,
:root[data-theme="light"] .status-pill.pending { color: #d97706; }
:root[data-theme="light"] .status-pill.get-new-crd-from-client { color: #db2777; }
:root[data-theme="light"] .status-pill.cancelled { color: #dc2626; }

/* Partner icons — darker in light mode */
:root[data-theme="light"] .partner-card-icon.customer { color: #6366f1; }
:root[data-theme="light"] .partner-card-icon.supplier { color: #9333ea; }
:root[data-theme="light"] .partner-card-icon.logistics { color: #2563eb; }

/* Notification priorities */
:root[data-theme="light"] .notif-priority.fire { color: #dc2626; }
:root[data-theme="light"] .notif-priority.decision { color: #d97706; }

/* Deal detail section borders */
:root[data-theme="light"] .deal-section-header { border-bottom-color: var(--ag-border); }

/* ══════════════════════════════════════════════
   DASHBOARD — Contextualized Feed
   ══════════════════════════════════════════════ */

.dashboard-page {
    padding: 16px 20px;
    max-width: 900px;
}

/* Stats Bar */
.dash-stats-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--ag-border);
}
.dash-stat {
    padding: 6px 14px;
    text-align: center;
}
.dash-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}
.dash-stat-label {
    font-size: 0.6875rem;
    color: var(--ag-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.dash-stat-fire .dash-stat-value { color: var(--ag-fire); }
.dash-stat-attention .dash-stat-value { color: var(--ag-attention); }

/* Loading/Empty */
.dash-loading {
    display: flex;
    justify-content: center;
    padding: 60px;
}
.dash-empty {
    text-align: center;
    padding: 60px 20px;
}
.dash-empty-icon {
    font-size: 2.5rem;
    opacity: 0.2;
    margin-bottom: 12px;
}
.dash-empty h3 {
    color: var(--ag-text-secondary);
    margin-bottom: 6px;
}
.dash-empty p {
    color: var(--ag-text-muted);
    max-width: 360px;
    margin: 0 auto;
    line-height: 1.5;
}

/* Zone containers */
.dash-zones {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dash-zone-empty { display: none; }

.dash-zone-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: var(--ag-radius-sm);
    transition: background var(--ag-transition);
}
.dash-zone-header:hover {
    background: var(--ag-bg-card);
}
.dash-zone-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
}
.dash-zone-count {
    font-size: 0.6875rem;
    padding: 1px 7px;
    border-radius: var(--ag-radius-full);
    font-weight: 700;
    line-height: 1.4;
}

/* Feed Items */
.dash-zone-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 4px 8px;
}

.dash-feed-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-left: 3px solid transparent;
    border-radius: var(--ag-radius-sm);
    text-decoration: none;
    color: inherit;
    transition: all var(--ag-transition);
    cursor: pointer;
}
.dash-feed-item:hover {
    background: var(--ag-bg-card-hover);
}

.dash-feed-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.dash-feed-body {
    flex: 1;
    min-width: 0;
}
.dash-feed-top {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}
.dash-feed-ref {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--ag-teal-light);
}
.dash-feed-title {
    font-size: 0.75rem;
    color: var(--ag-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}
.dash-feed-summary {
    font-size: 0.8125rem;
    color: var(--ag-text);
    line-height: 1.4;
}
.dash-feed-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 3px;
    font-size: 0.6875rem;
    color: var(--ag-text-muted);
}
.dash-feed-party i {
    margin-right: 3px;
}
.dash-feed-arrow {
    color: var(--ag-text-muted);
    font-size: 0.75rem;
    margin-top: 8px;
    opacity: 0;
    transition: opacity var(--ag-transition);
}
.dash-feed-item:hover .dash-feed-arrow {
    opacity: 1;
}


/* ══════════════════════════════════════════════
   DEAL WORKSPACE — Split Layout
   ══════════════════════════════════════════════ */

.deal-workspace {
    display: flex;
    height: calc(100vh - var(--ag-header-height));
    overflow: hidden;
}

.deal-ws-loading,
.deal-ws-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 60px;
}

/* ── Deal Sidebar ──────────────────────────── */
.deal-sidebar {
    width: 340px;
    min-width: 340px;
    border-right: 1px solid var(--ag-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--ag-bg);
}

.deal-sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--ag-border);
    flex-shrink: 0;
}
.deal-back-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ag-radius-sm);
    color: var(--ag-text-muted);
    text-decoration: none;
    transition: all var(--ag-transition);
}
.deal-back-btn:hover {
    background: var(--ag-bg-card);
    color: var(--ag-text);
}
.deal-sidebar-title-block {
    min-width: 0;
    flex: 1;
}
.deal-sidebar-ref {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--ag-teal-light);
}
.deal-sidebar-name {
    font-size: 0.75rem;
    color: var(--ag-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Stage Pipeline */
.deal-stage-pipeline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px 14px 6px;
}
.deal-stage-dot {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.6875rem;
    transition: all var(--ag-transition);
}
.deal-stage-dot.completed {
    background: var(--ag-teal-subtle);
    color: var(--ag-teal);
}
.deal-stage-dot.active {
    background: var(--ag-teal);
    color: white;
    box-shadow: 0 0 8px var(--ag-teal-glow);
}
.deal-stage-dot.future {
    background: var(--ag-bg-card);
    color: var(--ag-text-muted);
}
.deal-stage-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 14px 10px;
}

/* Sidebar Tabs */
.deal-sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--ag-border);
    flex-shrink: 0;
}
.deal-sidebar-tabs button {
    flex: 1;
    padding: 8px 4px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--ag-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--ag-font);
    cursor: pointer;
    transition: all var(--ag-transition);
}
.deal-sidebar-tabs button:hover {
    color: var(--ag-text-secondary);
}
.deal-sidebar-tabs button.active {
    color: var(--ag-teal-light);
    border-bottom-color: var(--ag-teal);
}
.tab-count {
    font-size: 0.625rem;
    background: var(--ag-bg-card);
    padding: 1px 5px;
    border-radius: var(--ag-radius-full);
    margin-left: 3px;
}

/* Sidebar Content (scrollable) */
.deal-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
}

.deal-sb-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.deal-sb-group {
    padding: 8px 0;
    border-bottom: 1px solid var(--ag-border);
}
.deal-sb-group:last-child { border-bottom: none; }

.deal-sb-group-title {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ag-text-muted);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.deal-sb-group-title i { font-size: 0.625rem; }

.deal-sb-field {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 3px 0;
    font-size: 0.8125rem;
}
.deal-sb-label {
    color: var(--ag-text-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
    min-width: 60px;
}
.deal-sb-value {
    text-align: right;
    color: var(--ag-text);
    font-weight: 500;
}
.deal-sb-highlight {
    background: var(--ag-bg-card);
    padding: 4px 6px;
    border-radius: var(--ag-radius-sm);
    margin: 2px -6px;
}

/* Parties */
.deal-sb-party {
    padding: 6px 0;
}
.deal-sb-party + .deal-sb-party {
    border-top: 1px solid var(--ag-border);
}
.deal-sb-party-role {
    font-size: 0.625rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--ag-text-muted);
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}
.deal-sb-party-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ag-text);
}
.deal-sb-party-detail {
    font-size: 0.75rem;
    color: var(--ag-text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}
.deal-sb-party-detail i { font-size: 0.625rem; }

/* Samples */
.deal-sb-sample {
    padding: 6px 0;
    border-bottom: 1px solid var(--ag-border);
}
.deal-sb-sample:last-child { border-bottom: none; }

/* Action */
.deal-sb-action {
    padding: 12px 0;
}

/* Order cards */
.deal-order-card {
    padding: 8px 10px;
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius-sm);
    margin-bottom: 6px;
}
.deal-order-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}
.deal-order-num {
    font-weight: 600;
    font-size: 0.8125rem;
}
.deal-order-detail {
    font-size: 0.75rem;
    color: var(--ag-text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}
.deal-order-detail i { font-size: 0.625rem; color: var(--ag-text-muted); }

/* Document rows */
.deal-doc-bar {
    height: 4px;
    background: var(--ag-bg-card);
    border-radius: 2px;
    margin-bottom: 4px;
    overflow: hidden;
}
.deal-doc-bar-fill {
    height: 100%;
    background: var(--ag-teal);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.deal-doc-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid var(--ag-border);
}
.deal-doc-row:last-child { border-bottom: none; }
.deal-doc-status {
    font-size: 0.8125rem;
    color: var(--ag-text-muted);
    margin-top: 1px;
}
.deal-doc-status.received { color: var(--ag-success); }
.deal-doc-status.missing { color: var(--ag-error); }
.deal-doc-info { flex: 1; min-width: 0; }
.deal-doc-name { font-size: 0.8125rem; }
.deal-doc-note { margin-top: 1px; }

/* Payment rows */
.deal-pay-row {
    padding: 6px 0;
    border-bottom: 1px solid var(--ag-border);
}
.deal-pay-row:last-child { border-bottom: none; }
.deal-pay-type {
    font-size: 0.75rem;
    text-transform: capitalize;
    color: var(--ag-text-secondary);
}
.deal-pay-amount {
    font-size: 0.8125rem;
    font-weight: 600;
}
.deal-pay-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    font-size: 0.75rem;
}
.pay-overdue { color: var(--ag-error); font-weight: 600; }
.pay-paid { color: var(--ag-success); }
.pay-due { color: var(--ag-attention); }


/* ── Deal Conversation ─────────────────────── */
.deal-conversation {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--ag-bg);
}

.deal-conv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid var(--ag-border);
    flex-shrink: 0;
}
.deal-conv-tabs {
    display: flex;
    gap: 2px;
}
.deal-conv-tabs button {
    padding: 6px 12px;
    background: none;
    border: none;
    border-radius: var(--ag-radius-sm);
    color: var(--ag-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--ag-font);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all var(--ag-transition);
}
.deal-conv-tabs button:hover {
    background: var(--ag-bg-card);
    color: var(--ag-text-secondary);
}
.deal-conv-tabs button.active {
    background: var(--ag-teal-subtle);
    color: var(--ag-teal-light);
}

/* Messages area */
.deal-conv-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.deal-conv-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
}

.deal-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: var(--ag-radius-sm);
    background: var(--ag-bg-card);
    border: 1px solid var(--ag-border);
}
.deal-msg.inbound {
    align-self: flex-start;
}
.deal-msg.outbound {
    align-self: flex-end;
    background: var(--ag-teal-subtle);
    border-color: rgba(13, 148, 136, 0.2);
}
.deal-msg-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
    font-size: 0.6875rem;
}
.deal-msg-sender {
    font-weight: 600;
    color: var(--ag-text);
}
.deal-msg-company {
    color: var(--ag-text-muted);
}
.deal-msg-channel {
    color: var(--ag-text-muted);
}
.deal-msg-time {
    margin-left: auto;
    color: var(--ag-text-muted);
}
.deal-msg-text {
    font-size: 0.8125rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Compose */
.deal-conv-compose {
    padding: 10px 16px;
    border-top: 1px solid var(--ag-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}
.deal-conv-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--ag-bg-input);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius-sm);
    color: var(--ag-text);
    font-family: var(--ag-font);
    font-size: var(--ag-font-size);
    resize: none;
    outline: none;
    transition: border-color var(--ag-transition);
}
.deal-conv-input:focus {
    border-color: var(--ag-teal);
}


/* ── Responsive ─────────────────────────────── */
@media (max-width: 900px) {
    .deal-workspace {
        flex-direction: column;
        height: auto;
    }
    .deal-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--ag-border);
    }
}

@media (max-width: 640px) {
    .settings-fields { grid-template-columns: 1fr; }
    .settings-invite-row { flex-direction: column; }
    .settings-tabs { overflow-x: auto; }
    .notif-triggers-grid { grid-template-columns: 1fr; }
    .dash-stats-bar { flex-wrap: wrap; }
}
