/* ═══════════════════════════════════════════════════════════════
   TTGroup Mini-CRM — KeepinCRM-inspired Design System
   Colors: Dark teal sidebar, white content, green accents
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Sidebar */
    --sidebar-bg: #1a2332;
    --sidebar-hover: #243044;
    --sidebar-active: rgba(0, 184, 148, 0.12);
    --sidebar-text: #8899aa;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 260px;
    --sidebar-collapsed: 64px;

    /* Primary palette */
    --primary: #00b894;
    --primary-light: #55efc4;
    --primary-dark: #009b7d;
    --primary-bg: rgba(0, 184, 148, 0.08);

    /* Accents */
    --accent-orange: #fdcb6e;
    --accent-red: #ff7675;
    --accent-blue: #74b9ff;
    --accent-purple: #a29bfe;
    --accent-green: #10b981;
    --accent-indigo: #6366f1;

    /* Neutrals */
    --bg: #f5f6fa;
    --card-bg: #ffffff;
    --border: #e8ecf1;
    --text: #2d3436;
    --text-secondary: #636e72;
    --text-muted: #b2bec3;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);

    /* Radius */
    --radius: 8px;
    --radius-lg: 12px;

    /* Transitions */
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html,
body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    transition: all var(--transition);
    z-index: 100;
    position: relative;
    /* Anchor for absolute toggle */
    overflow: visible;
}

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

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

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

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

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.logo-text {
    font-weight: 600;
    font-size: 16px;
    color: #fff;
    white-space: nowrap;
}

.sidebar-toggle {
    position: absolute;
    right: 20px;
    bottom: 24px;
    width: 28px;
    height: 28px;
    background: var(--sidebar-bg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    /* Slightly more prominent border */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--sidebar-text);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    /* Much higher than sidebar or content */
    transition: all var(--transition);
}

.sidebar-toggle:hover {
    color: #fff;
    background: var(--sidebar-hover);
}

.sidebar .sidebar-toggle {
    transition: all 0.3s;
}

/* Sidebar User */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: #fff;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

.user-role {
    color: var(--sidebar-text);
    font-size: 11px;
    margin-top: 2px;
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 12px 8px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

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

.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 12px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
    margin-bottom: 2px;
}

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

.nav-item.active {
    color: var(--primary-light);
    background: var(--sidebar-active);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

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

.nav-badge {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.nav-badge.accent {
    background: var(--accent-orange);
    color: var(--sidebar-bg);
}

.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 12px 8px;
}

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

/* ── Top Bar ───────────────────────────────────────────────── */
.topbar {
    height: 60px;
    min-height: 60px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 6px;
}

.topbar-search {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.topbar-search input {
    width: 100%;
    padding: 9px 16px 9px 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: all var(--transition);
    outline: none;
}

.topbar-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
    background: #fff;
}

.topbar-search input::placeholder {
    color: var(--text-muted);
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 300px;
}

.search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 9px 16px 9px 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: all var(--transition);
    outline: none;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.topbar-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.topbar-btn svg {
    width: 20px;
    height: 20px;
}

.notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
    border: 2px solid var(--card-bg);
}

/* ── Page Container ────────────────────────────────────────── */
.page-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Stats Grid ────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.orders {
    background: rgba(0, 184, 148, 0.1);
    color: var(--primary);
}

.stat-icon.revenue {
    background: rgba(253, 203, 110, 0.15);
    color: #e17055;
}

.stat-icon.clients {
    background: rgba(116, 185, 255, 0.15);
    color: var(--accent-blue);
}

.stat-icon.calls {
    background: rgba(162, 155, 254, 0.15);
    color: var(--accent-purple);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* ── Dashboard Grid ────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.card-body {
    padding: 20px;
}

/* ── Chart Bars ────────────────────────────────────────────── */
.chart-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chart-bar-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chart-bar-label {
    font-size: 13px;
    font-weight: 500;
    min-width: 80px;
    color: var(--text-secondary);
}

.chart-bar-track {
    flex: 1;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-bar-fill.prom {
    background: linear-gradient(90deg, #00b894, #55efc4);
}

.chart-bar-fill.opencart {
    background: linear-gradient(90deg, #0984e3, #74b9ff);
}

.chart-bar-fill.horoshop {
    background: linear-gradient(90deg, #e17055, #fdcb6e);
}

.chart-bar-fill.manual {
    background: linear-gradient(90deg, #a29bfe, #dfe6e9);
}

.chart-bar-value {
    font-size: 13px;
    font-weight: 600;
    min-width: 30px;
    text-align: right;
    color: var(--text);
}

/* ── Status List ───────────────────────────────────────────── */
.status-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--bg);
    transition: background var(--transition);
}

.status-item:hover {
    background: var(--border);
}

.status-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-dot.new {
    background: var(--accent-blue);
}

.status-dot.accepted {
    background: var(--primary);
}

.status-dot.in_progress {
    background: var(--accent-orange);
}

.status-dot.shipped {
    background: var(--accent-purple);
}

.status-dot.delivered {
    background: #00cec9;
}

.status-dot.completed {
    background: #00b894;
}

.status-dot.cancelled {
    background: var(--accent-red);
}

.status-dot.returned {
    background: #636e72;
}

.status-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.status-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* ── Filters ───────────────────────────────────────────────── */
.filters-panel {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px 20px;
    animation: fadeIn 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.filters-panel.hidden {
    display: none;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select,
.filter-group input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    outline: none;
    min-width: 130px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ── Multi-Select Filter ──────────────────────────────────── */
.multi-select-filter {
    position: relative;
    min-width: 130px;
}

.multi-select-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    outline: none;
    cursor: pointer;
    min-width: 130px;
    height: 38px;
    gap: 4px;
    transition: border-color var(--transition), box-shadow var(--transition);
    user-select: none;
}

.multi-select-toggle:hover {
    border-color: var(--primary-light, #74b9ff);
}

.multi-select-toggle.open,
.multi-select-toggle:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.multi-select-toggle.has-values {
    border-color: var(--primary);
    background: var(--primary-bg, rgba(0, 184, 148, 0.06));
}

.multi-select-toggle-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: var(--text-secondary);
}

.multi-select-toggle-badges {
    display: flex;
    flex-wrap: nowrap;
    gap: 3px;
    flex: 1;
    overflow: hidden;
}

.multi-select-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    background: var(--primary);
    color: #fff;
    white-space: nowrap;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 16px;
}

.multi-select-badge-more {
    background: var(--text-muted);
}

.multi-select-chevron {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.multi-select-toggle.open .multi-select-chevron {
    transform: rotate(180deg);
}

.multi-select-dropdown {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    min-width: 100%;
    max-height: 240px;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.10);
    z-index: 1000;
    display: none;
    animation: msDropIn 0.12s ease;
    padding: 4px 0;
}

@keyframes msDropIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.multi-select-dropdown.open {
    display: block;
}

.multi-select-option {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    transition: background 0.1s;
    user-select: none;
}

.multi-select-option:hover {
    background: var(--primary-bg, rgba(0, 184, 148, 0.08));
}

.multi-select-option input[type="checkbox"] {
    -webkit-appearance: checkbox;
    appearance: checkbox;
    width: 14px;
    height: 14px;
    min-width: 14px;
    min-height: 14px;
    max-width: 14px;
    max-height: 14px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
    flex-grow: 0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ── Data Tables ───────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table th {
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover:not(.empty-row) {
    background: var(--primary-bg);
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    color: var(--border);
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-state span {
    font-size: 13px;
}

/* Table Footer */
.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.table-info {
    font-size: 12px;
    color: var(--text-muted);
}

.pagination {
    display: flex;
    gap: 4px;
}

.pagination button {
    min-width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.pagination button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

/* ── Status Badges ─────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.badge-new {
    background: rgba(116, 185, 255, 0.15);
    color: #0984e3;
}

.badge-accepted {
    background: rgba(0, 184, 148, 0.12);
    color: #00b894;
}

.badge-in_progress {
    background: rgba(253, 203, 110, 0.2);
    color: #e17055;
}

.badge-shipped {
    background: rgba(162, 155, 254, 0.15);
    color: #6c5ce7;
}

.badge-delivered {
    background: rgba(0, 206, 201, 0.12);
    color: #00cec9;
}

.badge-completed {
    background: rgba(0, 184, 148, 0.15);
    color: #00b894;
}

.badge-cancelled {
    background: rgba(255, 118, 117, 0.12);
    color: #d63031;
}

.badge-returned {
    background: rgba(99, 110, 114, 0.12);
    color: #636e72;
}

/* Source badges */
.badge-prom {
    background: rgba(0, 184, 148, 0.12);
    color: #00b894;
}

.badge-opencart {
    background: rgba(9, 132, 227, 0.12);
    color: #0984e3;
}

.badge-horoshop {
    background: rgba(225, 112, 85, 0.12);
    color: #e17055;
}

.badge-manual {
    background: rgba(99, 110, 114, 0.1);
    color: #636e72;
}

.badge-rozetka {
    background: rgba(0, 158, 57, 0.12);
    color: #009e39;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quick-search-wrap {
    position: relative;
    width: 280px;
}

.quick-search-wrap input {
    width: 100%;
    height: 38px;
    padding: 8px 12px 8px 38px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13.5px;
    color: var(--text);
    transition: var(--transition);
    outline: none;
}

.quick-search-wrap input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.quick-search-wrap svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--text-muted);
    pointer-events: none;
}

.bulk-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    border: 1px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 12px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-md);
    animation: slideDown 0.3s ease;
    gap: 20px;
}

.bulk-actions-bar.hidden {
    display: none;
}

.bulk-info {
    font-size: 14px;
    white-space: nowrap;
}

.bulk-fields select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
}

.bulk-fields select:focus {
    border-color: var(--primary);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Inventory Accordion ──────────────────────────────────────── */
.inv-category {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.inv-category:hover {
    box-shadow: var(--shadow-sm);
}

.inv-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
    gap: 12px;
}

.inv-category-header:hover {
    background: var(--primary-bg);
}

.inv-chevron {
    transition: transform 0.25s ease;
    flex-shrink: 0;
    color: var(--text-muted);
}

.inv-category-header.expanded .inv-chevron {
    transform: rotate(180deg);
}

.inv-category-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.inv-category-count {
    font-size: 11px;
    font-weight: 700;
    background: var(--primary-bg);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

.inv-category-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.inv-category-header:hover .inv-category-actions {
    opacity: 1;
}

.inv-category-body {
    border-top: 1px solid var(--border);
}

.inv-table {
    margin: 0;
}

.inv-cat-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

.inv-product-cb {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--primary);
}

tr.inv-selected {
    background: rgba(0, 184, 148, 0.06) !important;
}

tr.inv-selected td {
    color: var(--text) !important;
}

.form-control-sm {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--card-bg);
    outline: none;
    transition: border-color var(--transition);
}

.form-control-sm:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 184, 148, 0.1);
}

/* ── Toast Notifications ─────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 12px 20px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--primary);
    min-width: 280px;
    max-width: 400px;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 0.3s ease;
    opacity: 0;
    pointer-events: auto;
}

.toast.visible {
    transform: translateX(0);
    opacity: 1;
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-message {
    font-size: 14px;
    font-weight: 500;
}

.toast-success { border-left-color: var(--accent-green); }
.toast-success .toast-icon { color: var(--accent-green); }

.toast-error { border-left-color: var(--accent-red); }
.toast-error .toast-icon { color: var(--accent-red); }

.toast-warning { border-left-color: var(--accent-orange); }
.toast-warning .toast-icon { color: var(--accent-orange); }

.col-visibility-dropdown {
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .15);
    padding: 8px 4px;
    z-index: 5000;
    min-width: 170px;
    max-height: 400px;
    overflow-y: auto;
}

.col-visibility-dropdown.hidden {
    display: none;
}

.col-visibility-dropdown label:hover {
    background: var(--primary-bg);
    border-radius: 6px;
}

/* ── Order Detail Page ──────────────────────────────────────── */
.order-detail-page {
    padding-bottom: 40px;
}

/* ── Compact Table Style (Gmail-inspired) ───────────────────── */
.data-table.compact {
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0;
}

.data-table.compact th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 6px 8px;
    white-space: nowrap;
    background: var(--primary-bg);
    border-bottom: 1px solid var(--border);
}

.data-table.compact td {
    padding: 5px 8px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.35;
}

/* On hover highlight entire row */
.data-table.compact tbody tr:hover td {
    background: var(--hover-bg, rgba(0, 0, 0, 0.02));
}

/* Date columns: stack date and time */
.dt-date {
    font-weight: 500;
    color: var(--text-primary);
    display: block;
}

.dt-time {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
}

/* Specific column overrides for compact tables */
.data-table.compact td.oc-items {
    white-space: normal;
    min-width: 300px;
    max-width: 450px;
    font-size: 12px;
    line-height: 1.4;
}

.data-table.compact td.oc-delivery_detail {
    white-space: normal;
    min-width: 180px;
    max-width: 250px;
    font-size: 11px;
}

.data-table.compact td.oc-client {
    min-width: 110px;
}

.data-table.compact td.oc-client a,
.data-table.compact td.oc-client span {
    font-weight: 500;
}

.data-table.compact td.oc-total_amount {
    font-weight: 600;
}

.data-table.compact .badge {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 4px;
}

.data-table.compact td.oc-actions {
    width: 36px;
    padding: 4px 6px;
}


/* Call disposition badges */
.badge-answered {
    background: rgba(0, 184, 148, 0.12);
    color: #00b894;
}

.badge-missed {
    background: rgba(255, 118, 117, 0.12);
    color: #d63031;
}

.badge-busy {
    background: rgba(253, 203, 110, 0.2);
    color: #e17055;
}

.badge-no_answer {
    background: rgba(99, 110, 114, 0.1);
    color: #636e72;
}

/* Direction badges */
.badge-inbound {
    background: rgba(116, 185, 255, 0.12);
    color: #0984e3;
}

.badge-outbound {
    background: rgba(162, 155, 254, 0.12);
    color: #6c5ce7;
}

/* AI analysis badge */
.badge-ai {
    background: linear-gradient(135deg, rgba(162, 155, 254, 0.15), rgba(0, 184, 148, 0.1));
    color: #6c5ce7;
    cursor: pointer;
    transition: all var(--transition);
}

.badge-ai:hover {
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.2);
    transform: translateY(-1px);
}

.badge-no-ai {
    background: rgba(178, 190, 195, 0.12);
    color: var(--text-muted);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(0, 184, 148, 0.3);
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover {
    background: #d1d5db;
    color: #111827;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-danger {
    background: var(--accent-red);
    color: #fff;
}

.btn-danger:hover {
    background: #d63031;
}

.btn-icon {
    padding: 6px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--bg);
    color: var(--primary);
}

/* ── Settings ──────────────────────────────────────────────── */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    max-width: 700px;
}

.settings-grid-2col {
    grid-template-columns: 1fr 1fr;
    max-width: 1200px;
    /* wider to accommodate two tables */
}

@media (max-width: 1024px) {
    .settings-grid-2col {
        grid-template-columns: 1fr;
    }
}

.integration-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.integration-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.integration-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    flex-shrink: 0;
}

.integration-logo.prom {
    background: linear-gradient(135deg, #00b894, #55efc4);
}

.integration-logo.opencart {
    background: linear-gradient(135deg, #0984e3, #74b9ff);
}

.integration-logo.horoshop {
    background: linear-gradient(135deg, #e17055, #fdcb6e);
}

.integration-logo.binotel {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
}

.integration-logo.gemini {
    background: linear-gradient(135deg, #4285f4, #34a853);
}

.integration-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.integration-info strong {
    font-size: 14px;
    color: var(--text);
}

.integration-status {
    font-size: 12px;
}

.integration-status.connected {
    color: var(--primary);
}

.integration-status.disconnected {
    color: var(--text-muted);
}

.webhook-url-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.webhook-url-box code {
    flex: 1;
    font-size: 13px;
    color: var(--primary);
    word-break: break-all;
}

/* ── Settings Forms ───────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="datetime-local"],
.form-group input[type="color"],
.form-group select,
.form-group textarea,
.input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-sizing: border-box;
    height: 38px;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="email"]:focus,
.form-group input[type="number"]:focus,
.form-group input[type="datetime-local"]:focus,
.form-group input[type="color"]:focus,
.form-group select:focus,
.form-group textarea:focus,
.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.12);
}

.form-group input::placeholder {
    color: var(--text-muted);
    font-size: 13px;
}

.form-group small {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}


/* Grid Utils */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Calendar Week View Grid */
.calendar-week-header {
    border-bottom: 1px solid var(--border);
}

.calendar-week-grid {
    border-left: 1px solid var(--border);
    width: 100%;
}

.calendar-week-day {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.calendar-week-day.today {
    background: #f8faff;
}

.dark-theme .calendar-week-day.today {
    background: #1e293b;
    /* slate-800 */
}

.week-day-header {
    padding: 8px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    width: 100%;
}

.week-day-name {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    display: block;
}

.week-day-number {
    font-size: 20px;
    font-weight: 500;
}

.calendar-events-week {
    flex: 1;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.calendar-events-week .calendar-event {
    margin: 0;
    min-height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    white-space: normal;
    word-break: break-word;
    border-left-width: 3px;
    border-left-style: solid;
}

.calendar-events-week .event-time {
    font-size: 10px;
    opacity: 0.7;
    margin-bottom: 2px;
}

.calendar-events-week .event-title {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
}


@media (max-width: 768px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

.settings-message {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

.settings-message.success {
    background: rgba(0, 184, 148, 0.1);
    color: #00b894;
    border: 1px solid rgba(0, 184, 148, 0.2);
}

.settings-message.error {
    background: rgba(255, 118, 117, 0.1);
    color: #d63031;
    border: 1px solid rgba(255, 118, 117, 0.2);
}

.settings-message.hidden {
    display: none;
}

.settings-grid .card {
    transition: box-shadow var(--transition);
}

.settings-grid .card:hover {
    box-shadow: var(--shadow-md);
}

.integration-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.integration-card {
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border);
}

.integration-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* ── Integration Toggle Switch ────────────────────────────── */
.integration-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg);
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.integration-toggle-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.integration-toggle-label strong {
    font-size: 14px;
    color: var(--text);
}

.integration-toggle-label span {
    font-size: 12px;
    color: var(--text-muted);
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    border-radius: 26px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.2);
}

/* Integration badge on cards */
.integration-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}

.integration-badge.badge-on {
    background: rgba(0, 184, 148, 0.12);
    color: var(--primary);
}

.integration-badge.badge-off {
    background: rgba(178, 190, 195, 0.15);
    color: var(--text-muted);
}

/* ── Modals ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.modal-lg {
    max-width: 900px;
}

.modal-xl {
    max-width: 1140px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

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

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px 24px 24px;
}

/* AI Analysis Card inside modal */
.ai-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
}

.ai-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
}

.ai-card-body {
    padding: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.ai-card-body p {
    margin-bottom: 8px;
}

.ai-actions-list {
    list-style: none;
    padding: 0;
}

.ai-actions-list li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.ai-actions-list li::before {
    content: '→';
    color: var(--primary);
    font-weight: 600;
    flex-shrink: 0;
}

.sentiment-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.sentiment-positive {
    background: rgba(0, 184, 148, 0.12);
    color: #00b894;
}

.sentiment-neutral {
    background: rgba(178, 190, 195, 0.15);
    color: #636e72;
}

.sentiment-negative {
    background: rgba(255, 118, 117, 0.12);
    color: #d63031;
}

.satisfaction-score {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.satisfaction-score span {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 400;
}

.topics-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.topic-tag {
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--bg);
    font-size: 12px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* ── Misc ──────────────────────────────────────────────────── */
.text-muted {
    color: var(--text-muted);
}

.text-primary {
    color: var(--primary);
}

/* Action buttons in table */
.row-actions {
    display: flex;
    gap: 4px;
}

/* Duration formatting */
.duration {
    font-variant-numeric: tabular-nums;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        transition: left 0.3s ease;
        z-index: 200;
    }

    .sidebar.open {
        left: 0;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .page-container {
        padding: 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .integration-cards-grid {
        grid-template-columns: 1fr;
    }

    .filters-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group select,
    .filter-group input {
        min-width: 100%;
    }

    .topbar-search {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Sidebar overlay for mobile ────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
}

.sidebar-overlay.active {
    display: block;
}

/* ── Loading skeleton ──────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

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

    100% {
        background-position: -200% 0;
    }
}

/* ── Settings Vertical Layout ──────────────────────────────── */
.settings-layout {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.settings-sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px;
    box-shadow: var(--shadow-sm);
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.settings-nav-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    transition: color 0.2s;
}

.settings-nav-item:hover {
    background: rgba(0, 184, 148, 0.05);
    /* very light primary */
    color: var(--text);
}

.settings-nav-item:hover svg {
    color: var(--primary);
}

.settings-nav-item.active {
    background: rgba(0, 184, 148, 0.1);
    color: var(--primary);
    font-weight: 600;
}

.settings-nav-item.active svg {
    color: var(--primary);
}

.settings-content {
    flex: 1;
    min-width: 0;
    /* Enable flex shrinking */
}

/* Base styles for tab content to still work with JS toggle */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .settings-layout {
        flex-direction: column;
        gap: 20px;
    }

    .settings-sidebar {
        width: 100%;
        padding: 8px;
    }
}

/* ── Collapsed Sidebar ───────────────────────────────────── */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
    min-width: var(--sidebar-collapsed);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-item span:first-of-type,
.sidebar.collapsed .nav-badge {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center !important;
    padding: 20px 0 !important;
}

.sidebar.collapsed .logo {
    justify-content: center !important;
    width: 100% !important;
}

.sidebar.collapsed .logo-icon {
    margin: 0 !important;
}



.sidebar.collapsed .sidebar-toggle:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: scale(1.1);
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

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

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px;
    gap: 0;
}

.sidebar.collapsed .nav-icon {
    margin: 0;
}

.sidebar.collapsed .nav-item::before {
    display: none;
}

/* ── Calendar (Tasks) ───────────────────────────────────────── */
.calendar-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-top: 8px;
    /* Extra breathing room from header */
}

.calendar-nav-group {
    display: flex;
    align-items: center;
    background: var(--bg);
    padding: 2px;
    border-radius: var(--radius);
    margin-right: 12px;
    height: 38px;
}

.calendar-grid-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.day-name {
    padding: 12px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(120px, 1fr);
    background: var(--border);
    gap: 1px;
}

.calendar-day {
    background: #fff;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 120px;
    transition: background var(--transition);
    position: relative;
    cursor: pointer;
}

.calendar-day:hover {
    background: #fafbfc;
}

.calendar-day.other-month {
    background: #fcfcfd;
}

.calendar-day.other-month .day-number {
    color: var(--text-muted);
}

.calendar-day.today {
    background: rgba(0, 184, 148, 0.02);
}

.calendar-day.today .day-number {
    background: var(--primary);
    color: #fff;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.day-number {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: block;
    width: max-content;
}

.calendar-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    max-height: 100px;
}

.calendar-event {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--accent-blue);
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 4px;
}

.calendar-event:hover {
    opacity: 0.85;
}

.calendar-event.status-completed {
    opacity: 0.6;
    text-decoration: line-through;
}

/* Status styles refinements */
.calendar-event:hover {
    transform: translateY(-1px);
}

.calendar-event.status-in_progress {
    background: var(--primary) !important;
}

.calendar-event.status-in_progress::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 6px solid #fff;
    margin-right: 2px;
}

.calendar-event.status-cancelled {
    background: #e1e4e8 !important;
    color: #6a737d !important;
    opacity: 0.4 !important;
    text-decoration: line-through !important;
}

/* Custom Tooltip */
.custom-tooltip-wrap {
    position: relative;
    display: inline-block;
    cursor: default;
}

.custom-tooltip-wrap::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--text);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 1000;
    margin-bottom: 6px;
    box-shadow: var(--shadow-sm);
}

.custom-tooltip-wrap::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    border-width: 5px;
    border-style: solid;
    border-color: var(--text) transparent transparent transparent;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    margin-bottom: -4px;
    z-index: 1000;
}

.custom-tooltip-wrap:hover::after,
.custom-tooltip-wrap:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ── Toggle Switch ─────────────────────────────────────────── */
.toggle-switch input:checked + span {
    background-color: var(--primary) !important;
}

.toggle-switch span::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + span::before {
    transform: translateX(20px);
}

/* Message Template Dropdown */
.msg-template-dd-item:hover {
    background-color: var(--bg-hover, #f3f4f6);
}

/* ── Mail Page ─────────────────────────────────────────────── */
.mail-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - 180px);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.mail-sidebar {
    width: 260px;
    min-width: 260px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    background: var(--bg);
}

.mail-sidebar-section {
    padding: 12px 0;
}

.mail-sidebar-section:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.mail-sidebar-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 8px 16px 6px;
}

.mail-account-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.mail-account-item:hover {
    background: rgba(0, 184, 148, 0.06);
}

.mail-account-item.active {
    background: rgba(0, 184, 148, 0.1);
}

.mail-account-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.mail-account-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #00cec9);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

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

.mail-account-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-account-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-default-badge {
    color: var(--primary);
    font-size: 14px;
    font-weight: 700;
}

.mail-folder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.15s;
    border-radius: 0;
}

.mail-folder-item:hover {
    background: rgba(0, 184, 148, 0.06);
    color: var(--text);
}

.mail-folder-item.active {
    background: rgba(0, 184, 148, 0.1);
    color: var(--primary);
    font-weight: 600;
}

.mail-folder-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.mail-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mail-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.mail-pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mail-table {
    border: none !important;
    table-layout: fixed;
    width: 100%;
}

.mail-table tbody tr {
    border-bottom: 1px solid var(--border);
}

.mail-row {
    transition: background 0.15s;
}

.mail-row:hover {
    background: rgba(0, 184, 148, 0.03) !important;
}

.mail-row.mail-unread {
    background: rgba(0, 184, 148, 0.04);
}

.mail-row.mail-unread .mail-from-cell .mail-from-name {
    color: var(--text);
    font-weight: 700;
}

.mail-row.mail-unread .mail-subject-cell {
    font-weight: 600;
    color: var(--text);
}

.mail-from-cell {
    width: 220px;
    overflow: hidden;
}

.mail-from-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    line-height: 1.3;
}

.mail-from-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    line-height: 1.3;
}

.mail-subject-cell {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-date-cell {
    width: 110px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
}

.mail-actions-cell {
    width: 40px;
    text-align: center;
}

/* Mail checkbox column */
.mail-check-cell {
    width: 36px;
    min-width: 36px;
    text-align: center;
    cursor: pointer;
}

.mail-check-cell input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

.mail-select-all-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.mail-select-all-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

.mail-row.mail-selected {
    background: rgba(0, 184, 148, 0.08) !important;
}

/* Scrollable table area */
.mail-table-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* Bulk action bar */
.mail-bulk-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(0, 184, 148, 0.06);
    border-bottom: 1px solid var(--border);
    animation: fadeIn 0.2s ease;
}

.mail-bulk-actions {
    display: flex;
    gap: 6px;
    flex: 1;
}

/* Mail Detail Panel */
.mail-detail-panel {
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
}

.mail-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Mail Detail View */
.mail-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.mail-detail-actions {
    display: flex;
    gap: 8px;
}

.mail-detail-meta {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.mail-detail-subject {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 12px;
}

.mail-detail-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.mail-detail-info strong {
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 6px;
}

.mail-attachments {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    font-size: 13px;
}

.mail-attach-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    margin: 4px 4px 0 0;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .mail-layout {
        flex-direction: column;
        height: auto;
    }
    .mail-sidebar {
        width: 100%;
        min-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 200px;
    }
    .mail-from-cell {
        width: 120px;
        max-width: 120px;
    }
    .mail-bulk-actions {
        flex-wrap: wrap;
    }
}

/* Optimize settings tables spacing to prevent text overlap */
.settings-content .data-table th,
.settings-content .data-table td {
    padding: 10px 8px !important;
}
.settings-content .data-table th {
    font-size: 11px !important;
}

/* Manager Cards Dashboard Visual Refactoring */
.manager-card {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.25s !important;
}

.manager-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg) !important;
    border-color: var(--primary) !important;
}

.manager-card .avatar-glow {
    position: relative;
    z-index: 1;
}

.manager-card .avatar-glow::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, var(--primary), var(--accent-purple));
    border-radius: 50%;
    z-index: -1;
    opacity: 0.3;
    filter: blur(4px);
    transition: opacity 0.25s;
}

.manager-card:hover .avatar-glow::after {
    opacity: 0.7;
}

/* Modern loading spin animations for refresh buttons */
.loading-spin svg {
    animation: refreshSpin 0.8s linear infinite;
}

@keyframes refreshSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Premium interactive client link styling */
.client-link {
    transition: color 0.2s ease, text-decoration 0.2s ease;
}
.client-link:hover {
    color: var(--primary) !important;
    text-decoration: underline !important;
}
