/* ==========================================================================
   Sales Hub — Layout CSS
   Sidebar navigation, top bar, and main content area layout.
   Pure CSS3, no preprocessors, no frameworks.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Layout Variables
   -------------------------------------------------------------------------- */
:root {
    --sidebar-w: 260px;
    --sidebar-w-collapsed: 64px;
    --topbar-h: 56px;
    --sidebar-bg: #1a1f2e;
    --sidebar-bg-hover: rgba(255, 255, 255, 0.06);
    --sidebar-bg-active: rgba(255, 122, 0, 0.1);
    --sidebar-text: rgba(255, 255, 255, 0.7);
    --sidebar-text-active: #ffffff;
    --sidebar-divider: rgba(255, 255, 255, 0.08);
    --sidebar-accent: var(--primary, #FF7A00);
    --topbar-bg: #ffffff;
    --topbar-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* --------------------------------------------------------------------------
   2. Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 200ms ease;
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-w-collapsed);
}

/* Sidebar Header / Logo */
.sidebar-header {
    padding: 20px;
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    white-space: nowrap;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: var(--sidebar-accent);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    border-radius: 8px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    transition: opacity 200ms ease;
}

.sidebar.collapsed .logo-text {
    opacity: 0;
    pointer-events: none;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 150ms ease;
    white-space: nowrap;
    position: relative;
    cursor: pointer;
}

.nav-item:hover {
    color: var(--sidebar-text-active);
    background: var(--sidebar-bg-hover);
}

.nav-item.active {
    color: var(--sidebar-text-active);
    background: var(--sidebar-bg-active);
    border-left-color: var(--sidebar-accent);
}

.nav-item .nav-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.nav-item .nav-label {
    transition: opacity 200ms ease;
    overflow: hidden;
}

/* Sub-navigation items (indented, smaller) */
.nav-sub-item {
    padding-left: 36px;
    font-size: 13px;
}

.nav-sub-item .nav-icon {
    width: 16px;
    height: 16px;
}

.sidebar.collapsed .nav-sub-item {
    padding-left: 0;
}

.sidebar.collapsed .nav-item {
    padding: 10px 0;
    justify-content: center;
    border-left-width: 0;
}

.sidebar.collapsed .nav-item.active {
    border-left-width: 0;
    background: var(--sidebar-bg-active);
    border-radius: 0;
}

.sidebar.collapsed .nav-item .nav-label {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

/* Collapsed sidebar tooltip */
.sidebar.collapsed .nav-item:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(var(--sidebar-w-collapsed) + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--sidebar-bg);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    z-index: 1100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    pointer-events: none;
}

/* Nav divider */
.nav-divider {
    height: 1px;
    margin: 8px 20px;
    background: var(--sidebar-divider);
}

.sidebar.collapsed .nav-divider {
    margin: 8px 12px;
}

/* Sidebar Footer */
.sidebar-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--sidebar-divider);
    padding: 8px 0 0;
}

.sidebar-footer .nav-item {
    margin-bottom: 4px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    overflow: hidden;
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: var(--sidebar-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

.user-details {
    flex: 1;
    min-width: 0;
    transition: opacity 200ms ease;
}

.user-name {
    display: block;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-role {
    display: block;
    color: var(--sidebar-text);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-logout {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 150ms ease, background 150ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-logout:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.sidebar.collapsed .user-details,
.sidebar.collapsed .user-logout {
    opacity: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
}

.sidebar.collapsed .user-info {
    justify-content: center;
    padding: 12px 0;
}

/* Tenant Switcher (sidebar) */
.tenant-switcher {
    padding: 4px 12px 8px;
    position: relative;
}

.tenant-switcher-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    transition: background 150ms ease, border-color 150ms ease;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tenant-switcher-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--sidebar-accent);
}

.tenant-switcher-icon {
    flex-shrink: 0;
    color: var(--sidebar-accent);
}

.tenant-switcher-name {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tenant-switcher-chevron {
    flex-shrink: 0;
    color: var(--sidebar-text);
    transition: transform 150ms ease;
}

.tenant-switcher-dropdown.open + .tenant-switcher-btn .tenant-switcher-chevron,
.tenant-switcher-btn[aria-expanded="true"] .tenant-switcher-chevron {
    transform: rotate(180deg);
}

.tenant-switcher-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    left: 12px;
    right: 12px;
    background: var(--sidebar-bg);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 4px;
    z-index: 1100;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
}

.tenant-switcher-dropdown.open {
    display: block;
}

.tenant-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    text-align: left;
    transition: background 150ms ease, color 150ms ease;
}

.tenant-dropdown-item:hover {
    background: rgba(255, 122, 0, 0.15);
    color: #fff;
}

.tenant-dropdown-name {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tenant-dropdown-role {
    flex-shrink: 0;
    font-size: 10px;
    color: var(--sidebar-text);
    opacity: 0.7;
}

/* Static tenant label (single tenant) */
.tenant-label-static {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px 8px;
    color: var(--sidebar-text);
    font-size: 11px;
    font-weight: 500;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tenant-label-static svg {
    flex-shrink: 0;
    opacity: 0.6;
}

/* Collapsed sidebar: hide tenant switcher text */
.sidebar.collapsed .tenant-switcher,
.sidebar.collapsed .tenant-label-static {
    display: none !important;
}

/* Tenant Badge (top bar) */
.tenant-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: var(--primary-light, rgba(255, 122, 0, 0.1));
    color: var(--primary, #FF7A00);
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    white-space: nowrap;
    margin-right: 8px;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   3. Mobile Sidebar Overlay
   -------------------------------------------------------------------------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 200ms ease;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* --------------------------------------------------------------------------
   3b. Dark Mode Toggle (in sidebar)
   -------------------------------------------------------------------------- */
.dark-mode-toggle-wrapper {
    padding: 4px 16px 8px;
}

.dark-mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 4px;
    border-radius: 6px;
    transition: background 150ms ease;
    user-select: none;
}

.dark-mode-toggle:hover {
    background: var(--sidebar-bg-hover);
}

.dark-mode-icon {
    display: flex;
    align-items: center;
    color: var(--sidebar-text);
    flex-shrink: 0;
}

.dark-mode-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--sidebar-text);
    flex: 1;
    transition: opacity 200ms ease;
}

.sidebar.collapsed .dark-mode-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
}

.sidebar.collapsed .dark-mode-toggle-wrapper {
    padding: 4px 8px 8px;
    display: flex;
    justify-content: center;
}

.sidebar.collapsed .dark-mode-slider {
    display: none;
}

.dark-mode-checkbox {
    display: none;
}

.dark-mode-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    transition: background 200ms ease;
    flex-shrink: 0;
}

.dark-mode-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 200ms ease;
}

.dark-mode-checkbox:checked + .dark-mode-slider {
    background: var(--sidebar-accent, #FF7A00);
}

.dark-mode-checkbox:checked + .dark-mode-slider::after {
    transform: translateX(16px);
}

/* --------------------------------------------------------------------------
   4. Main Content Area
   -------------------------------------------------------------------------- */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 200ms ease, background 200ms ease;
    background: #f5f6fa;
}

.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-w-collapsed);
}

/* --------------------------------------------------------------------------
   5. Top Bar
   -------------------------------------------------------------------------- */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-h);
    padding: 0 24px;
    background: var(--topbar-bg);
    box-shadow: var(--topbar-shadow);
    flex-shrink: 0;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 8px;
    color: var(--gray-600, #4b5563);
    cursor: pointer;
    transition: all 150ms ease;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--gray-100, #f3f4f6);
    color: var(--gray-900, #111827);
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--gray-500, #6b7280);
    min-width: 0;
    overflow: hidden;
}

.breadcrumb-link {
    color: var(--gray-500, #6b7280);
    text-decoration: none;
    white-space: nowrap;
    transition: color 150ms ease;
}

.breadcrumb-link:hover {
    color: var(--primary, #FF7A00);
}

.breadcrumb-sep {
    color: var(--gray-300, #d1d5db);
    user-select: none;
}

.breadcrumb-current {
    color: var(--gray-900, #111827);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Top bar actions */
.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Global Search */
.search-global {
    position: relative;
}

.search-global .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400, #9ca3af);
    pointer-events: none;
}

.search-input {
    width: 220px;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 8px;
    font-size: 13px;
    color: var(--gray-900, #111827);
    background: var(--gray-50, #f9fafb);
    transition: all 200ms ease;
    outline: none;
}

.search-input::placeholder {
    color: var(--gray-400, #9ca3af);
}

.search-input:focus {
    width: 300px;
    border-color: var(--primary, #FF7A00);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.1);
}

/* Notification Button */
.notification-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 8px;
    color: var(--gray-600, #4b5563);
    cursor: pointer;
    transition: all 150ms ease;
}

.notification-btn:hover {
    background: var(--gray-100, #f3f4f6);
    color: var(--gray-900, #111827);
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger, #e74c3c);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--topbar-bg);
}

/* --------------------------------------------------------------------------
   6. Page Content
   -------------------------------------------------------------------------- */
.page-content {
    flex: 1;
    padding: 24px;
}

/* When the contact detail wrapper is a direct child, remove padding
   because the 3-column layout handles its own spacing */
.page-content:has(.contact-detail-wrapper) {
    padding: 0;
}

.contact-detail-wrapper {
    min-height: calc(100vh - var(--topbar-h, 56px));
}

/* --------------------------------------------------------------------------
   7. Mobile Responsive (<768px)
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-w);
        transition: transform 200ms ease;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: var(--sidebar-w);
        transform: translateX(-100%);
    }

    .sidebar.collapsed.mobile-open {
        transform: translateX(0);
    }

    .main-content,
    .main-content.sidebar-collapsed {
        margin-left: 0;
    }

    .search-input {
        width: 140px;
    }

    .search-input:focus {
        width: 180px;
    }

    .page-content {
        padding: 16px;
    }

    .top-bar {
        padding: 0 16px;
    }
}

/* --------------------------------------------------------------------------
   8. Tablet Responsive (768px - 1024px)
   -------------------------------------------------------------------------- */
@media (min-width: 768px) and (max-width: 1024px) {
    .search-input {
        width: 180px;
    }

    .search-input:focus {
        width: 240px;
    }
}

/* --------------------------------------------------------------------------
   9. Utility: Btn Icon (shared)
   -------------------------------------------------------------------------- */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 150ms ease;
    color: inherit;
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* --------------------------------------------------------------------------
   10. Dashboard Specific Styles
   -------------------------------------------------------------------------- */

/* Welcome */
.dashboard-welcome {
    margin-bottom: 24px;
}

.dashboard-welcome h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900, #111827);
    margin-bottom: 4px;
}

.dashboard-welcome p {
    font-size: 14px;
    color: var(--gray-500, #6b7280);
}

/* KPI Cards Row */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--gray-100, #f3f4f6);
    transition: box-shadow 200ms ease, transform 200ms ease;
}

.kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.kpi-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.kpi-card-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500, #6b7280);
}

.kpi-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-card-icon.blue { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.kpi-card-icon.green { background: rgba(34, 197, 94, 0.1); color: #22c55e; }
.kpi-card-icon.orange { background: rgba(255, 122, 0, 0.1); color: #FF7A00; }
.kpi-card-icon.purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }

.kpi-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900, #111827);
    line-height: 1.2;
    margin-bottom: 4px;
}

.kpi-card-sub {
    font-size: 12px;
    color: var(--gray-400, #9ca3af);
}

.kpi-card-trend {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.kpi-card-trend.up {
    color: #16a34a;
    background: rgba(34, 197, 94, 0.1);
}

.kpi-card-trend.down {
    color: #dc2626;
    background: rgba(239, 68, 68, 0.1);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.dashboard-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--gray-100, #f3f4f6);
    overflow: hidden;
}

.dashboard-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100, #f3f4f6);
}

.dashboard-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900, #111827);
}

.dashboard-card-action {
    font-size: 13px;
    color: var(--primary, #FF7A00);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}

.dashboard-card-action:hover {
    text-decoration: underline;
}

.dashboard-card-body {
    padding: 20px;
}

.dashboard-card.full-width {
    grid-column: 1 / -1;
}

/* Chart placeholder */
.chart-container {
    width: 100%;
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chart-container canvas {
    max-width: 100%;
    max-height: 100%;
}

/* Task list */
.task-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100, #f3f4f6);
}

.task-item:last-child {
    border-bottom: none;
}

.task-check {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--gray-300, #d1d5db);
    flex-shrink: 0;
    cursor: pointer;
    transition: all 150ms ease;
}

.task-check:hover {
    border-color: var(--primary, #FF7A00);
}

.task-check.done {
    background: var(--primary, #FF7A00);
    border-color: var(--primary, #FF7A00);
}

.task-info {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-900, #111827);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-due {
    font-size: 11px;
    color: var(--gray-400, #9ca3af);
}

.task-due.overdue {
    color: var(--danger, #e74c3c);
    font-weight: 600;
}

.task-priority {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    flex-shrink: 0;
}

.task-priority.high { background: rgba(239, 68, 68, 0.1); color: #dc2626; }
.task-priority.medium { background: rgba(245, 158, 11, 0.1); color: #d97706; }
.task-priority.low { background: rgba(34, 197, 94, 0.1); color: #16a34a; }

/* Activity Table */
.activity-table {
    width: 100%;
    border-collapse: collapse;
}

.activity-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
}

.activity-table td {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--gray-700, #374151);
    border-bottom: 1px solid var(--gray-100, #f3f4f6);
}

.activity-table tr:last-child td {
    border-bottom: none;
}

.activity-table tr:hover td {
    background: var(--gray-50, #f9fafb);
}

.activity-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gray-200, #e5e7eb);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-600, #4b5563);
    vertical-align: middle;
    margin-right: 8px;
}

.activity-contact-name {
    font-weight: 500;
    color: var(--gray-900, #111827);
}

.activity-action {
    font-size: 12px;
    color: var(--gray-500, #6b7280);
}

.activity-date {
    font-size: 12px;
    color: var(--gray-400, #9ca3af);
    white-space: nowrap;
}

/* Provision Section */
.provision-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.provision-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--gray-100, #f3f4f6);
    text-align: center;
}

.provision-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500, #6b7280);
    margin-bottom: 8px;
}

.provision-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900, #111827);
}

.provision-value.green { color: #16a34a; }
.provision-value.orange { color: #FF7A00; }

/* Progress Arc */
.progress-arc-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.progress-arc {
    width: 80px;
    height: 80px;
    margin-bottom: 8px;
}

.progress-arc-bg {
    fill: none;
    stroke: var(--gray-200, #e5e7eb);
    stroke-width: 6;
}

.progress-arc-fill {
    fill: none;
    stroke: var(--primary, #FF7A00);
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 600ms ease;
}

.progress-arc-text {
    font-size: 16px;
    font-weight: 700;
    fill: var(--gray-900, #111827);
}

/* Appointment List */
.appointment-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.appointment-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100, #f3f4f6);
}

.appointment-item:last-child {
    border-bottom: none;
}

.appointment-time {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary, #FF7A00);
    min-width: 50px;
}

.appointment-info {
    flex: 1;
    min-width: 0;
}

.appointment-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-900, #111827);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.appointment-contact {
    font-size: 11px;
    color: var(--gray-400, #9ca3af);
}

/* Empty state */
.empty-state-small {
    text-align: center;
    padding: 24px 16px;
    color: var(--gray-400, #9ca3af);
    font-size: 13px;
}

.empty-state-small svg {
    margin: 0 auto 8px;
    color: var(--gray-300, #d1d5db);
}

/* Dashboard loading skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100, #f3f4f6) 25%, var(--gray-50, #f9fafb) 50%, var(--gray-100, #f3f4f6) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --------------------------------------------------------------------------
   11. KPI Row Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
    .kpi-row,
    .provision-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    .kpi-row,
    .provision-row {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* --------------------------------------------------------------------------
   12. Login Page Styles
   -------------------------------------------------------------------------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1f2e 0%, #2c3e50 50%, #1a1f2e 100%);
    padding: 16px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    width: 48px;
    height: 48px;
    font-size: 24px;
}

.login-logo .logo-text {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900, #111827);
}

.login-title {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900, #111827);
    margin-bottom: 24px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700, #374151);
    margin-bottom: 6px;
}

.login-form input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300, #d1d5db);
    border-radius: 8px;
    font-size: 14px;
    color: var(--gray-900, #111827);
    transition: border-color 200ms ease, box-shadow 200ms ease;
    outline: none;
}

.login-form input:focus {
    border-color: var(--primary, #FF7A00);
    box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.1);
}

.login-form input::placeholder {
    color: var(--gray-400, #9ca3af);
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary, #FF7A00);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 200ms ease, transform 100ms ease;
}

.login-btn:hover {
    background: var(--primary-dark, #cc6200);
}

.login-btn:active {
    transform: scale(0.98);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #dc2626;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

.login-error.visible {
    display: block;
}

/* --------------------------------------------------------------------------
   13. Dark Mode — body.dark
   Sidebar stays dark always. Only main content area switches.
   -------------------------------------------------------------------------- */
body.dark .main-content {
    background: #1a1d23;
}

body.dark .top-bar {
    background: #22262e;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

body.dark .sidebar-toggle {
    border-color: #3a3f4b;
    color: #9ca3af;
}

body.dark .sidebar-toggle:hover {
    background: #2d323c;
    color: #fff;
}

body.dark .breadcrumb-link {
    color: #9ca3af;
}

body.dark .breadcrumb-current {
    color: #e5e7eb;
}

body.dark .breadcrumb-sep {
    color: #4b5563;
}

body.dark .search-input {
    background: #2d323c;
    border-color: #3a3f4b;
    color: #e5e7eb;
}

body.dark .search-input::placeholder {
    color: #6b7280;
}

body.dark .search-input:focus {
    background: #2d323c;
    border-color: var(--primary, #FF7A00);
}

body.dark .notification-btn {
    border-color: #3a3f4b;
    color: #9ca3af;
}

body.dark .notification-btn:hover {
    background: #2d323c;
    color: #fff;
}

body.dark .page-content {
    color: #e5e7eb;
}

/* Dark mode — Dashboard cards */
body.dark .kpi-card,
body.dark .dashboard-card,
body.dark .provision-card {
    background: #22262e;
    border-color: #2d323c;
}

body.dark .kpi-card-value,
body.dark .dashboard-card-title,
body.dark .provision-value {
    color: #e5e7eb;
}

body.dark .kpi-card-label,
body.dark .provision-label {
    color: #9ca3af;
}

body.dark .dashboard-welcome h1 {
    color: #e5e7eb;
}

body.dark .dashboard-welcome p {
    color: #9ca3af;
}

body.dark .dashboard-card-header {
    border-bottom-color: #2d323c;
}

body.dark .task-item {
    border-bottom-color: #2d323c;
}

body.dark .task-title {
    color: #e5e7eb;
}

body.dark .activity-table th {
    border-bottom-color: #3a3f4b;
    color: #9ca3af;
}

body.dark .activity-table td {
    border-bottom-color: #2d323c;
    color: #d1d5db;
}

body.dark .activity-table tr:hover td {
    background: #2d323c;
}

body.dark .activity-contact-name {
    color: #e5e7eb;
}

/* Dark mode — Contact Detail Page */
body.dark .contact-left-sidebar,
body.dark .contact-right-sidebar {
    background: #22262e;
    border-color: #2d323c;
}

body.dark .contact-identity {
    border-bottom-color: #2d323c;
}

body.dark .contact-identity-name {
    color: #e5e7eb;
}

body.dark .contact-identity-company {
    color: #9ca3af;
}

body.dark .detail-section {
    border-bottom-color: #2d323c;
}

body.dark .detail-row {
    border-bottom-color: #2d323c;
}

body.dark .detail-label {
    color: #9ca3af;
}

body.dark .detail-value {
    color: #d1d5db;
}

body.dark .contact-tabs {
    background: #22262e;
    border-bottom-color: #2d323c;
}

body.dark .contact-tab {
    color: #9ca3af;
}

body.dark .contact-tab:hover {
    color: #e5e7eb;
}

body.dark .contact-tab.active {
    color: var(--primary);
}

body.dark .action-btn {
    background: #22262e;
    border-color: #3a3f4b;
    color: #9ca3af;
}

body.dark .action-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(255, 122, 0, 0.08);
}

body.dark .timeline-search,
body.dark .timeline-filter {
    background: #22262e;
    border-color: #3a3f4b;
    color: #d1d5db;
}

body.dark .timeline-title {
    color: #e5e7eb;
}

body.dark .timeline-desc {
    color: #9ca3af;
}

body.dark .timeline-item {
    border-bottom-color: #2d323c;
}

body.dark .timeline::before {
    background: #3a3f4b;
}

body.dark .timeline-dot {
    background: #22262e;
}

body.dark .timeline-load-more {
    background: #22262e;
    border-color: #3a3f4b;
}

body.dark .pinned-section {
    background: rgba(255, 122, 0, 0.06);
    border-color: rgba(255, 122, 0, 0.2);
}

body.dark .sidebar-section {
    border-bottom-color: #2d323c;
}

body.dark .sidebar-section-header:hover {
    background: #2d323c;
}

body.dark .sidebar-section-title {
    color: #e5e7eb;
}

body.dark .sidebar-section-count {
    background: #2d323c;
    color: #9ca3af;
}

body.dark .sidebar-item:hover {
    background: #2d323c;
}

body.dark .sidebar-item-title {
    color: #d1d5db;
}

body.dark .document-item {
    background: #22262e;
    border-color: #2d323c;
}

body.dark .document-item:hover {
    background: #2d323c;
}

body.dark .document-name {
    color: #e5e7eb;
}

body.dark .dropdown-menu {
    background: #22262e;
    border-color: #3a3f4b;
}

body.dark .dropdown-menu a,
body.dark .dropdown-menu button {
    color: #d1d5db;
}

body.dark .dropdown-menu a:hover,
body.dark .dropdown-menu button:hover {
    background: #2d323c;
}

body.dark .dropdown-divider {
    background: #3a3f4b;
}

body.dark .loading-spinner {
    color: #6b7280;
}

body.dark .empty-state {
    color: #6b7280;
}

/* Dark mode — Login page is excluded (always has its own bg) */

/* Dark mode — List Pages (tables, filters, badges, kanban) */
body.dark .list-header h1 {
    color: #e5e7eb;
}

body.dark .filter-bar {
    background: #22262e;
    border-color: #2d323c;
}

body.dark .filter-group label {
    color: #9ca3af;
}

body.dark .filter-group input,
body.dark .filter-group select {
    background: #2a3040;
    border-color: #3a3f4b;
    color: #e5e7eb;
}

body.dark .filter-group input:focus,
body.dark .filter-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(255, 122, 0, 0.2);
}

body.dark .filter-group input::placeholder {
    color: #6b7280;
}

body.dark .table-wrapper {
    background: #22262e;
    border-color: #2d323c;
}

body.dark .data-table th {
    background: #1e2230;
    border-bottom-color: #3a3f4b;
    color: #9ca3af;
}

body.dark .data-table td {
    border-bottom-color: #2d323c;
    color: #d1d5db;
}

body.dark .data-table tbody tr:hover {
    background: rgba(255, 122, 0, 0.04);
}

body.dark .data-table tbody tr:nth-child(even) {
    background: rgba(30, 34, 48, 0.5);
}

body.dark .data-table tbody tr:nth-child(even):hover {
    background: rgba(255, 122, 0, 0.04);
}

body.dark .data-table tbody tr.row-overdue {
    background: rgba(239, 68, 68, 0.08);
}

body.dark .data-table td a.row-link {
    color: #d1d5db;
}

body.dark .data-table td a.row-link:hover {
    color: var(--primary);
}

body.dark .contact-cell .cell-text .name {
    color: #d1d5db;
}

body.dark .contact-cell .cell-text .name:hover {
    color: var(--primary);
}

body.dark .score-bar {
    color: #9ca3af;
}

body.dark .score-bar .bar-track {
    background: #3a3f4b;
}

body.dark .pagination button,
body.dark .pagination a {
    background: #22262e;
    border-color: #3a3f4b;
    color: #d1d5db;
}

body.dark .pagination button:hover:not(:disabled):not(.active),
body.dark .pagination a:hover:not(.active) {
    background: #2d323c;
    border-color: var(--primary);
    color: var(--primary);
}

body.dark .pagination button.active,
body.dark .pagination a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

body.dark .pagination .page-info {
    color: #9ca3af;
}

body.dark .btn-export {
    background: #22262e;
    border-color: #3a3f4b;
    color: #9ca3af;
}

body.dark .btn-export:hover {
    border-color: var(--primary);
    color: var(--primary);
}

body.dark .view-toggle {
    border-color: #3a3f4b;
}

body.dark .view-toggle button {
    background: #22262e;
    color: #9ca3af;
}

body.dark .view-toggle button + button {
    border-left-color: #3a3f4b;
}

body.dark .view-toggle button.active {
    background: var(--primary);
    color: #fff;
}

body.dark .view-toggle button:hover:not(.active) {
    background: #2d323c;
}

/* Dark mode — Pipeline / Kanban */
body.dark .pipeline-summary {
    background: #22262e;
    border-color: #2d323c;
}

body.dark .pipeline-summary__label {
    color: #9ca3af;
}

body.dark .pipeline-summary__value {
    color: #e5e7eb;
}

body.dark .pipeline-stage {
    background: #1e2230;
    border-color: #2d323c;
}

body.dark .pipeline-stage__header {
    background: #22262e;
}

body.dark .pipeline-stage__count {
    background: #3a3f4b;
    color: #9ca3af;
}

body.dark .pipeline-card {
    background: #22262e;
    border-color: #3a3f4b;
}

body.dark .pipeline-card:hover {
    border-color: #4b5563;
}

body.dark .pipeline-card__name {
    color: #e5e7eb;
}

body.dark .pipeline-card__company {
    color: #6b7280;
}

body.dark .pipeline-card__meta {
    color: #6b7280;
}

body.dark .pipeline-stage.drag-over {
    background: rgba(255, 122, 0, 0.06);
}

/* Dark mode — Bulk action bar */
body.dark .bulk-bar {
    background: rgba(255, 122, 0, 0.08);
    border-color: rgba(255, 122, 0, 0.25);
}

/* Dark mode — Detail Pages (deal, offer, company) */
body.dark .detail-wrapper {
    background: #1a1d23;
}

body.dark .detail-left-sidebar,
body.dark .detail-right-sidebar {
    background: #22262e;
    border-color: #2d323c;
}

body.dark .detail-identity {
    border-bottom-color: #2d323c;
}

body.dark .detail-identity-name {
    color: #e5e7eb;
}

body.dark .detail-identity-sub {
    color: #9ca3af;
}

body.dark .detail-identity-meta {
    color: #6b7280;
}

body.dark .detail-action-bar .back-link {
    color: #9ca3af;
}

body.dark .detail-action-bar .back-link:hover {
    color: var(--primary);
}

body.dark .detail-tabs {
    background: #22262e;
    border-bottom-color: #2d323c;
}

body.dark .detail-tab {
    color: #9ca3af;
}

body.dark .detail-tab:hover {
    color: #e5e7eb;
}

body.dark .detail-tab.active {
    color: var(--primary);
}

body.dark .pipeline-stepper {
    background: #22262e;
    border-color: #2d323c;
}

body.dark .pipeline-step-circle {
    background: #22262e;
    border-color: #4b5563;
    color: #6b7280;
}

body.dark .pipeline-step-line {
    background: #3a3f4b;
}

body.dark .pipeline-step-label {
    color: #9ca3af;
}

body.dark .deal-value-display {
    color: #e5e7eb;
}

body.dark .deal-probability {
    color: #9ca3af;
}

body.dark .deal-probability-bar {
    background: #3a3f4b;
}

body.dark .positions-table thead {
    background: #1e2230;
}

body.dark .positions-table th {
    color: #9ca3af;
    border-bottom-color: #3a3f4b;
}

body.dark .positions-table td {
    color: #d1d5db;
    border-bottom-color: #2d323c;
}

body.dark .positions-table tbody tr:nth-child(even) {
    background: rgba(30, 34, 48, 0.5);
}

body.dark .positions-table tbody tr:hover {
    background: rgba(255, 122, 0, 0.04);
}

body.dark .totals-row {
    color: #9ca3af;
}

body.dark .totals-row.total {
    color: #e5e7eb;
}

body.dark .totals-separator {
    background: #3a3f4b;
}

body.dark .sign-timeline::before {
    background: #3a3f4b;
}

body.dark .sign-step-dot {
    background: #22262e;
}

body.dark .sign-step-title {
    color: #e5e7eb;
}

body.dark .sign-step.pending .sign-step-title {
    color: #6b7280;
}

body.dark .recipient-block {
    background: #1e2230;
    border-color: #2d323c;
}

body.dark .recipient-name {
    color: #e5e7eb;
}

body.dark .recipient-company,
body.dark .recipient-address {
    color: #9ca3af;
}

body.dark .offer-title {
    color: #e5e7eb;
}

body.dark .offer-actions .action-btn {
    background: #22262e;
    border-color: #3a3f4b;
    color: #9ca3af;
}

body.dark .offer-actions .action-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(255, 122, 0, 0.08);
}

body.dark .offer-detail-page {
    background: #1a1d23;
}

body.dark .offer-right-sidebar {
    background: #22262e;
    border-color: #2d323c;
}

body.dark .company-name-large {
    color: #e5e7eb;
}

body.dark .company-industry {
    color: #9ca3af;
}

body.dark .info-grid {
    background: #22262e;
    border-color: #2d323c;
}

body.dark .info-grid-label {
    color: #6b7280;
}

body.dark .info-grid-value {
    color: #d1d5db;
}

body.dark .stat-card {
    background: #22262e;
    border-color: #2d323c;
}

body.dark .stat-card-label {
    color: #6b7280;
}

body.dark .stat-card-value {
    color: #e5e7eb;
}

body.dark .content-card {
    background: #22262e;
    border-color: #2d323c;
}

body.dark .content-card-header {
    border-bottom-color: #2d323c;
}

body.dark .content-card-header h3 {
    color: #e5e7eb;
}

body.dark .version-list li {
    border-bottom-color: #2d323c;
}

body.dark .version-list .version-current {
    color: #e5e7eb;
}

body.dark .send-history-item {
    border-bottom-color: #2d323c;
}

body.dark .send-history-recipient {
    color: #d1d5db;
}

body.dark .signature-preview {
    background: #1e2230;
    border-color: #2d323c;
}

body.dark .notes-display {
    color: #9ca3af;
}

/* Dark mode — Modal & Forms */
body.dark .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

body.dark .modal {
    background: #22262e;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

body.dark .modal-header {
    border-bottom-color: #2d323c;
}

body.dark .modal-header h3 {
    color: #e5e7eb;
}

body.dark .modal-close {
    color: #6b7280;
}

body.dark .modal-close:hover {
    color: #e5e7eb;
}

body.dark .modal-body {
    color: #d1d5db;
}

body.dark .modal-footer {
    border-top-color: #2d323c;
}

body.dark .form-label {
    color: #9ca3af;
}

body.dark .form-control {
    background: #2a3040;
    border-color: #3a3f4b;
    color: #e5e7eb;
}

body.dark .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.2);
}

body.dark .form-control::placeholder {
    color: #6b7280;
}

body.dark .form-control:disabled,
body.dark .form-control[readonly] {
    background: #1e2230;
    color: #6b7280;
}

body.dark .form-text {
    color: #6b7280;
}

/* Dark mode — Alerts */
body.dark .alert-success {
    background: rgba(39, 174, 96, 0.12);
    border-color: rgba(39, 174, 96, 0.25);
    color: #4ade80;
}

body.dark .alert-danger {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

body.dark .alert-warning {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.25);
    color: #fbbf24;
}

body.dark .alert-info {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.25);
    color: #60a5fa;
}

/* --------------------------------------------------------------------------
   14. Print Styles
   -------------------------------------------------------------------------- */
@media print {
    .sidebar,
    .sidebar-overlay,
    .top-bar {
        display: none !important;
    }

    .main-content,
    .main-content.sidebar-collapsed {
        margin-left: 0 !important;
    }

    .page-content {
        padding: 0 !important;
    }
}
