* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Primary Colors */
    --primary: #0077FF;
    --primary-dark: #0056CC;
    --secondary: #6c757d;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #ffc107;
    --light: #f8f9fa;
    --dark: #343a40;
    --border: #dee2e6;

    /* Text Colors */
    --text-primary: #333;
    --text-secondary: #666;
    --text-muted: #999;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 20px;

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

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 20px;

    /* Transitions */
    --transition-fast: 0.2s;
    --transition-normal: 0.3s;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
}

/* Navigation */
.navbar {
    background: white;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--primary);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 1rem;
    background: white;
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: var(--spacing-lg) var(--spacing-xl);
    text-align: center;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

.stat-card h3 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

/* Cards */
.card {
    background: white;
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 1rem;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    transition: all var(--transition-fast);
    font-weight: 500;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

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

.btn-block {
    width: 100%;
    display: block;
}

.btn-icon {
    padding: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--light);
    border: 1px solid var(--border);
    color: var(--secondary);
}

.btn-icon:hover {
    background: var(--border);
    border-color: var(--secondary);
    color: var(--dark);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: border-color var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #6c757d;
}

/* Quick Links (for fast value selection) */
.quick-links {
    margin-top: 6px;
    font-size: 12px;
    color: #666;
}

.quick-links a {
    color: var(--primary);
    text-decoration: none;
    margin: 0 4px;
}

.quick-links a:hover {
    text-decoration: underline;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    color: var(--dark);
}

/* Community Card */
.community-card {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 1.5rem;
    align-items: center;
}

.community-avatar-column {
    display: flex;
    align-items: center;
    justify-content: center;
}

.community-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

.community-avatar-placeholder {
    width: 60px;
    height: 60px;
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary);
}

.community-info {
    min-width: 0;
}

.community-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.community-info h3 {
    margin-bottom: 0.25rem;
}

.community-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.25rem;
}

.badge-info {
    background: var(--primary);
    color: white;
    padding: 4px 8px;
    border-radius: var(--radius-lg);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Info Box */
.info-box {
    background: #f8f9fa;
    border-left: 4px solid var(--primary);
    padding: var(--spacing-lg);
    margin-bottom: 1.5rem;
    border-radius: var(--radius-md);
}

.info-box p {
    margin-bottom: 0.5rem;
}

.info-box ol {
    font-size: 0.9rem;
    color: #495057;
    margin-left: 1.5rem;
    padding-left: 0;
}

/* Dialog List */
.dialog-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dialog-item {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s;
}

.dialog-item:hover {
    transform: translateY(-2px);
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.dialog-preview {
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dialog-time {
    color: #6c757d;
}

.badge {
    background: var(--danger);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.badge-new { background: var(--primary); }
.badge-confirmed { background: #17a2b8; }
.badge-paid { background: var(--success); }
.badge-shipped { background: var(--warning); }
.badge-delivered { background: var(--secondary); }
.badge-cancelled { background: #dc3545; }
.badge-problem { background: #dc3545; }
.badge-refunded { background: #6610f2; }
.badge-other { background: #8B4513; /* коричневый цвет */ }

/* Dialog Order Indicator */
.dialog-order-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    flex-shrink: 0;
    align-self: stretch;
    margin: -0.75rem -1rem -0.75rem 0;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.dialog-order-icon {
    width: 14px;
    height: 14px;
    color: white;
}

.dialog-order-new { background: var(--primary); }
.dialog-order-confirmed { background: #17a2b8; }
.dialog-order-paid { background: var(--success); }
.dialog-order-shipped { background: var(--warning); }
.dialog-order-delivered { background: var(--secondary); }
.dialog-order-cancelled { background: #dc3545; }
.dialog-order-problem { background: #dc3545; }
.dialog-order-refunded { background: #6610f2; }

/* Dialog Container */
.dialog-container {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 1.5rem;
}

.dialog-main {
    display: flex;
    flex-direction: column;
}

/* Messages */
.message-container {
    background: white;
    padding: 1.5rem;
    height: 500px;
    overflow-y: auto;
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.message {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.message-incoming {
    justify-content: flex-start;
}

.message-outgoing {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: var(--radius-md);
}

.message-content p {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.35;
}

.message-incoming .message-content {
    background: #e9ecef;
}

.message-outgoing .message-content {
    background: var(--primary);
    color: white;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.6;
    color: #9ca3af;
    flex-shrink: 0;
    padding-top: 0.35rem;
    white-space: nowrap;
}

.message-outgoing .message-time {
    order: -1;
}

.message-incoming .message-time {
    order: 1;
}


/* Message Input */
.message-input-container {
    background: white;
    padding: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.message-input-group {
    display: flex;
    gap: 1rem;
}

.message-input-group textarea {
    flex: 1;
    min-height: 60px;
    resize: vertical;
}

/* Dialog Sidebar */
.dialog-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Orders */
.orders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.order-card {
    display: flex;
    flex-direction: column;
    gap: 0;
}

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

.order-details p {
    margin: 0.5rem 0;
}

.order-actions {
    display: flex;
    gap: 0.5rem;
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

/* Quick Actions */
.quick-actions {
    background: white;
    padding: 2rem;
}

.quick-actions ol {
    margin-left: 2rem;
}

.quick-actions li {
    margin: 1rem 0;
}

/* Utilities */
.text-muted {
    color: #6c757d;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .nav-links {
        gap: 1rem;
        font-size: 0.9rem;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

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

    .dialog-container {
        grid-template-columns: 1fr;
    }

    .dialog-sidebar {
        order: -1;
    }

    .message-content {
        max-width: 85%;
    }

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

    .community-card {
        grid-template-columns: 60px 1fr;
        gap: 1rem;
        align-items: start;
    }

    .community-avatar-column {
        grid-row: 1;
        grid-column: 1;
        justify-content: flex-start;
    }

    .community-info {
        grid-row: 1;
        grid-column: 2;
        padding-left: 0;
    }

    .community-actions {
        grid-row: 2;
        grid-column: 1 / -1;
        justify-content: flex-start;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border);
        margin-top: 0.5rem;
    }

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

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    /* Ensure consistent padding on all pages */
    .container {
        padding: 0;
    }

    .card {
        padding: 1rem;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
        padding: 0.75rem 1rem;
    }

    .nav-links {
        width: 100%;
        justify-content: space-around;
    }

    .hero {
        padding: 1.5rem 1rem;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .message-input-group {
        flex-direction: column;
    }

    .message-input-group .btn {
        width: 100%;
    }

    /* Extra small screens - reduce all padding */
    .container {
        padding: 0;
    }

    .card {
        padding: 0.75rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .stat-card {
        padding: 1.5rem 1rem;
    }

    .community-card {
        grid-template-columns: 50px 1fr;
    }

    .community-avatar {
        width: 50px;
        height: 50px;
    }

    .community-avatar-placeholder {
        width: 50px;
        height: 50px;
    }

    .info-box {
        padding: 0.75rem;
        margin-left: 0;
        margin-right: 0;
    }

    .info-box ol {
        margin-left: 1rem;
        padding-left: 0.5rem;
        font-size: 0.85rem;
    }

    .form-group label {
        font-size: 0.9rem;
    }

    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 0.95rem;
    }
}

/* AI Panel Styles */
#ai-summary {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 1rem;
    min-height: 100px;
}

.order-item {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.order-item strong {
    display: block;
    margin-bottom: 0.5rem;
}


/* Success and Error Messages */
.success-message {
    padding: 1rem;
    margin: 1rem 0;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    color: #155724;
}

.error-message {
    padding: 1rem;
    margin: 1rem 0;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    color: #721c24;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.tab-button {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--secondary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: -2px;
}

.tab-button:hover {
    color: var(--primary);
    background-color: rgba(0, 119, 255, 0.05);
}

.tab-button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

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

/* Three Column Layout Styles */
.three-column-layout {
    display: grid;
    grid-template-columns: 300px 1fr 480px;
    gap: 1rem;
    height: calc(100vh - 120px);
    max-width: 100%;
    margin: 0 auto;
}

.column {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.column-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: #f8f9fa;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.column-header h2 {
    font-size: 1.25rem;
    margin: 0;
    flex-grow: 1;
}

.column-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.mobile-back-button {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--primary);
    font-weight: 500;
    align-items: center;
    gap: 0.25rem;
}

/* Dialog List Item */
.dialog-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-left: 4px solid transparent;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    cursor: pointer;
}

.dialog-list-item:hover {
    background: #f8f9fa;
}

.dialog-list-item.active {
    background: #dbeafe;
    border-left-color: #2563eb;
}

.dialog-list-item.htmx-request {
    opacity: 0.7;
    position: relative;
}

.dialog-list-item.htmx-request::after {
    content: '';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 119, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

.dialog-avatars {
    display: flex;
    align-items: center;
    position: relative;
    width: 60px;
    flex-shrink: 0;
}

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
}

.avatar-community {
    position: absolute;
    left: 0;
    z-index: 1;
    background: #e3f2fd;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.avatar-user {
    position: absolute;
    left: 20px;
    z-index: 2;
    background: #f3e5f5;
    color: #9c27b0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

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

.dialog-name {
    font-weight: 500;
    margin-right: 0.5rem;
    transition: color 0.2s ease;
}

/* Filter Toolbar */
.filter-toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: white;
}

.filter-icon-btn {
    position: relative;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-icon-btn:hover {
    background: #f8f9fa;
    color: var(--primary);
}

.filter-icon-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.filter-search-expanded {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 1rem;
    background: white;
}

.filter-search-expanded.show {
    max-height: 80px;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.filter-search-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}

.filter-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 200px;
    z-index: 100;
}

.filter-dropdown.show {
    display: block;
}

.filter-dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.filter-dropdown-item:hover {
    background: #f8f9fa;
}

.filter-dropdown-item.selected {
    background: var(--primary);
    color: white;
    font-weight: 500;
}


/* Empty States */
.empty-state-icon-small {
    margin-bottom: 1rem;
}

/* AI Controls */
.ai-controls {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 1rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.ai-model-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.btn-ai-model {
    padding: 0.5rem 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--primary);
    background: white;
    color: var(--primary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    white-space: nowrap;
}

.btn-ai-model:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}


/* Responsive: stack buttons on small screens */
@media (max-width: 768px) {
    .ai-model-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
}

.ai-summary-placeholder {
    text-align: center;
    padding: 2rem;
    color: var(--secondary);
}

/* AI Tabs */
.ai-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.ai-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 13px;
    color: var(--secondary);
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.ai-tab:hover {
    background: #f8f9fa;
    color: var(--primary);
}

.ai-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 500;
}

.ai-tab svg {
    width: 16px;
    height: 16px;
}

/* AI Tab Content */
.ai-tab-content {
    display: none;
}

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

/* Dialog Stats Grid */
.dialog-stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dialog-stat-card {
    flex: 1 1 70px;
    min-width: 70px;
    background: #f8f9fa;
    padding: 0.75rem 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.dialog-stat-value {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
}

.dialog-stat-unit {
    font-size: 12px;
    font-weight: 400;
    color: var(--secondary);
    margin-left: 2px;
}

.dialog-stat-icon {
    color: var(--secondary);
    opacity: 0.7;
}

.dialog-stat-value.zero {
    color: #9ca3af;
}

.dialog-stat-value.positive {
    color: #10b981;
}

.dialog-placeholder {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--secondary);
}

/* Dialog AI Section */
.dialog-ai-section {
    margin-top: 1rem;
}

.dialog-ai-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.dialog-ai-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.dialog-ai-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .three-column-layout {
        grid-template-columns: 1fr;
        height: calc(100vh - 80px);
    }

    .column {
        display: none;
    }

    .column.mobile-active {
        display: flex;
    }

    .mobile-back-button {
        display: flex;
    }
}

/* Dialog Header with Avatars */
.dialog-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dialog-header-avatars {
    display: flex;
    align-items: center;
    position: relative;
    margin-left: -4px;
}

.dialog-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
}

.dialog-header-avatar.avatar-fallback {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.dialog-header-avatar.avatar-user {
    margin-left: -8px;
    z-index: 2;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.dialog-header-text {
    display: flex;
    flex-direction: column;
    gap: 0px;
    min-width: 0;
}

.dialog-header-community {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.dialog-header-username {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 0;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-hover);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.close-btn:hover {
    color: var(--danger);
}

.modal-content form {
    padding: 1.5rem;
}

.form-section {
    margin-bottom: 2rem;
}

.form-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--primary);
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    position: sticky;
    bottom: 0;
    background: white;
    margin-top: 2rem;
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}


/* AI Suggest Buttons */
.message-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.btn-ai-suggest {
    padding: 0.6rem;
    border: 1px solid;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 44px;
    min-height: 44px;
}

.btn-ai-suggest:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}


/* DeepSeek branding - Blue */
.btn-ai-suggest-deepseek {
    border-color: #1E88E5;
    color: #1E88E5;
    background: rgba(30, 136, 229, 0.05);
}

.btn-ai-suggest-deepseek:hover:not(:disabled) {
    background: rgba(30, 136, 229, 0.15);
    border-color: #1565C0;
}

/* Claude branding - Orange */
.btn-ai-suggest-claude {
    border-color: #CC785C;
    color: #CC785C;
    background: rgba(204, 120, 92, 0.05);
}

.btn-ai-suggest-claude:hover:not(:disabled) {
    background: rgba(204, 120, 92, 0.15);
    border-color: #B85C3D;
}

/* Order analyze section styling */
.order-analyze-section {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.order-analyze-section .btn-ai-model {
    flex: 1;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* View Toggle Buttons */
.view-toggle {
    display: flex;
    gap: 0.5rem;
    background: white;
    padding: 0.25rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-view-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--secondary);
}

.btn-view-toggle:hover {
    background: var(--light);
    color: var(--primary);
}

.btn-view-toggle.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 119, 255, 0.2);
}

.btn-view-toggle svg {
    display: block;
}

/* Enhanced Order Card Styles */
.order-card {
    padding: 0 !important;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.order-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: none;
}

.order-user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-left: 1rem;
    flex: 1;
    min-width: 0;
}

.order-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.order-avatar-placeholder {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
}

.order-header-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    flex: 1;
}

.order-number {
    font-size: 0.75rem;
    font-weight: 400;
    color: #999;
}

.order-number-highlight {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--dark);
    margin-left: 0.15rem;
}

.order-vk-user {
    font-size: 1rem;
    color: var(--dark);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.order-card-header .badge {
    margin-right: 1rem;
}

.order-card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.order-section {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.order-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.order-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.order-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.order-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.order-label {
    font-size: 0.75rem;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.order-value {
    font-size: 0.95rem;
    color: var(--dark);
    font-weight: 500;
}

.order-tracking {
    font-family: 'Courier New', monospace;
    color: var(--primary);
    font-weight: 600;
}

.order-address {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--dark);
}

.order-pricing {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.order-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.order-price-row.order-total {
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 2px solid var(--border);
    font-weight: 600;
    font-size: 1.1rem;
}

.order-price-value {
    font-weight: 600;
    color: var(--primary);
}

.order-notes {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--dark);
    background: var(--light);
    padding: 0.75rem;
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

.order-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--light);
    border-top: none;
}

.order-timestamp {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--secondary);
}

.order-timestamp svg {
    opacity: 0.6;
}

.order-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

/* Compact Order Card Styles */
.order-number-line {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.order-number {
    font-size: 0.75rem;
    font-weight: 400;
    color: #999;
}

.order-date {
    font-size: 0.7rem;
    color: #999;
    margin-top: 0.15rem;
}

.order-vk-user {
    font-size: 0.95rem;
    color: var(--dark);
    font-weight: 500;
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-header-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.btn-icon-tiny {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: #999;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-tiny:hover {
    color: var(--primary);
    transform: scale(1.1);
}

.order-card-header .badge {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
}

.order-card-header {
    position: relative;
}

.order-copy-section {
    padding: 0 0 0.35rem 0;
    margin-bottom: 0.35rem;
    display: flex;
    justify-content: flex-end;
}

.btn-copy-production {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--light);
    border: 1px solid var(--border);
    padding: 0.4rem;
    border-radius: 6px;
    color: var(--dark);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy-production:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.btn-copy-production svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.btn-icon {
    background: white;
    border: 1px solid var(--border);
    padding: 0.4rem;
    cursor: pointer;
    color: var(--dark);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.btn-icon:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-1px);
}

.order-section-compact {
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

.order-section-compact:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.order-info-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.25rem 0;
}

.order-label-icon {
    font-size: 1rem;
    min-width: 20px;
    text-align: center;
    opacity: 0.8;
}

.order-value {
    flex: 1;
    font-size: 0.85rem;
    color: var(--dark);
    line-height: 1.4;
}

.order-value-expandable {
    cursor: pointer;
    position: relative;
}

.order-value-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-value-expandable.expanded .order-value-text {
    -webkit-line-clamp: unset;
}

.order-info-clickable {
    cursor: pointer;
    transition: all 0.2s;
}

.order-info-clickable:hover {
    background: var(--light);
    margin: -0.35rem;
    padding: 0.35rem;
    border-radius: 4px;
}

.order-value-link {
    color: var(--primary);
    font-weight: 500;
}

.order-pricing-compact {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.order-price-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.order-label-small {
    color: var(--secondary);
    font-size: 0.8rem;
}

.order-price {
    font-weight: 500;
    color: var(--dark);
}

.order-price-total {
    margin-top: 0.25rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.order-price-bold {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
}

.btn-icon-only {
    padding: 0.5rem !important;
    min-width: auto !important;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.btn-icon-only svg {
    margin: 0 !important;
}

.order-card-body {
    padding: 0.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.order-card-footer {
    padding: 0.75rem 1.25rem;
    margin-top: auto;
}

.order-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Products Modal */
#products-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.products-modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.products-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.products-modal-header h3 {
    margin: 0;
    color: var(--dark);
}

.products-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.products-modal-close:hover {
    background: var(--light);
    color: var(--dark);
}

.products-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.product-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    transition: all 0.2s;
}

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

.product-item:hover {
    background: var(--light);
    margin: 0 -1rem;
    padding: 1rem 2rem;
}

.product-name {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.product-details {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--secondary);
}

/* Orders Table Styles */
.orders-table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border);
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table thead {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid var(--border);
}

.orders-table th {
    padding: 1rem;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.orders-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: all 0.2s;
}

.orders-table tbody tr:hover {
    background: var(--light);
}

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

.order-table-cell {
    padding: 0.5rem 1rem;
    vertical-align: middle;
}

.order-table-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.order-table-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.order-table-user-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.order-table-number {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.95rem;
}

.order-table-vk {
    font-size: 0.8rem;
    color: var(--secondary);
}

.order-table-customer {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.order-table-meta {
    font-size: 0.8rem;
    color: var(--secondary);
}

.order-table-address {
    font-size: 0.9rem;
    line-height: 1.4;
    max-width: 250px;
}

.order-table-price {
    text-align: right;
}

.order-price-display {
    font-weight: 600;
    color: var(--primary);
    font-size: 1rem;
}

.order-table-status-cell {
    text-align: center;
}

.order-table-date {
    text-align: center;
    font-size: 0.9rem;
}

.order-table-actions-cell {
    text-align: right;
}

.order-table-actions {
    display: flex;
    gap: 0.25rem;
    justify-content: flex-end;
}

.order-table-products {
    font-size: 0.85rem;
    line-height: 1.5;
}

.order-product-item {
    color: var(--dark);
    margin-bottom: 0.15rem;
}

.order-product-item:last-child {
    margin-bottom: 0;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 1px solid var(--border);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    color: var(--secondary);
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-icon-sm {
    padding: 0.4rem;
}

.btn-icon-sm svg {
    width: 16px;
    height: 16px;
}

.btn-icon-danger:hover {
    background: #fee;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-icon-success {
    background: transparent;
    color: #10b981;
    border: 1px solid transparent;
}

.btn-icon-success:hover {
    background: #ecfdf5;
    color: #059669;
    border-color: #10b981;
}

/* Copy notification */
.copy-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #10b981;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.copy-notification.show {
    opacity: 1;
    transform: translateY(0);
}

/* Expandable text */
.expandable-text-container {
    display: flex;
    align-items: center;
    gap: 4px;
}

.expandable-text {
    flex: 1;
    word-break: break-word;
}

.btn-expand {
    flex-shrink: 0;
    background: transparent;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.btn-expand:hover {
    background: var(--background-secondary);
    color: var(--primary);
}

.btn-expand svg {
    transition: transform 0.2s ease;
}

.expandable-text-container.expanded .btn-expand svg {
    transform: rotate(180deg);
}

/* Responsive Orders */
@media (max-width: 768px) {
    .orders-grid {
        grid-template-columns: 1fr;
    }

    .order-info-grid {
        grid-template-columns: 1fr;
    }

    .order-actions {
        width: 100%;
    }

    .order-actions .btn-sm {
        flex: 1;
        justify-content: center;
    }

    .order-card-footer {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .order-timestamp {
        justify-content: center;
    }

    /* Hide table on mobile, show cards only */
    .orders-table-container {
        overflow-x: auto;
    }

    .orders-table {
        min-width: 800px;
    }

    .view-toggle {
        display: flex;
    }
}

@media (max-width: 480px) {
    .order-card-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .order-user-info {
        width: 100%;
    }
}

/* Orders Page Improvements */

/* Smaller page title */
.page-title-small {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

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

.stat-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.stat-card-highlight {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.stat-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card-highlight .stat-label {
    color: rgba(255, 255, 255, 0.9);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #333;
}

.stat-card-highlight .stat-value {
    color: white;
}

/* Search Bar */
.search-bar {
    position: relative;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0 12px;
}

.search-bar svg {
    color: #999;
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px;
    font-size: 14px;
}

.search-clear {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.search-clear:hover {
    color: #666;
}

/* Filter Buttons */
.btn-filter {
    padding: 6px 12px;
    font-size: 13px;
    background: #f5f5f5;
    color: #666;
    border: 1px solid #e0e0e0;
    transition: all 0.2s;
}

.btn-filter:hover {
    background: #eee;
    color: #333;
}

.btn-filter.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Sortable Table Headers */
.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.sortable:hover {
    background: #f5f5f5;
}

.sort-icon {
    margin-left: 4px;
    display: inline-block;
    width: 0;
    height: 0;
    opacity: 0.3;
}

.sort-icon.sort-asc::after {
    content: '▲';
    opacity: 1;
    color: #667eea;
}

.sort-icon.sort-desc::after {
    content: '▼';
    opacity: 1;
    color: #667eea;
}

/* Small Order Number */
.order-table-number-small {
    font-size: 11px;
    color: #999;
    font-weight: 400;
}

/* Currency Small */
.currency-small {
    font-size: 10px;
    color: #999;
    white-space: nowrap;
}

.order-price-display {
    white-space: nowrap;
}

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

    .page-title-small {
        font-size: 16px;
    }

    .stat-value {
        font-size: 20px;
    }
}

/* ========================================
   COMPACT ORDER CARD STYLES (Refactored)
   ======================================== */

/* Body background - always white */
.order-card .order-card-body { background: #ffffff; }

/* Status-based header tints */
.order-card-new .order-card-header { background: linear-gradient(135deg, rgba(0, 119, 255, 0.06) 0%, rgba(0, 119, 255, 0.10) 100%); }
.order-card-confirmed .order-card-header { background: linear-gradient(135deg, rgba(23, 162, 184, 0.06) 0%, rgba(23, 162, 184, 0.10) 100%); }
.order-card-paid .order-card-header { background: linear-gradient(135deg, rgba(40, 167, 69, 0.06) 0%, rgba(40, 167, 69, 0.10) 100%); }
.order-card-shipped .order-card-header { background: linear-gradient(135deg, rgba(255, 193, 7, 0.08) 0%, rgba(255, 193, 7, 0.12) 100%); }
.order-card-delivered .order-card-header { background: linear-gradient(135deg, rgba(108, 117, 125, 0.06) 0%, rgba(108, 117, 125, 0.10) 100%); }
.order-card-cancelled .order-card-header { background: linear-gradient(135deg, rgba(220, 53, 69, 0.06) 0%, rgba(220, 53, 69, 0.10) 100%); }
.order-card-problem .order-card-header { background: linear-gradient(135deg, rgba(220, 53, 69, 0.08) 0%, rgba(220, 53, 69, 0.12) 100%); }
.order-card-refunded .order-card-header { background: linear-gradient(135deg, rgba(102, 16, 242, 0.06) 0%, rgba(102, 16, 242, 0.10) 100%); }

/* Footer background - always gray */
.order-card .order-card-footer { background: #f5f5f5; }

/* Header with name and date on same line */
.order-header-main {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    min-width: 0;
}

.order-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.order-header-top .order-vk-user {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.order-header-top .order-date {
    font-size: 0.7rem;
    color: #999;
    white-space: nowrap;
    margin: 0;
    flex-shrink: 0;
}

/* Compact body */
.order-card .order-card-body {
    padding: 0.6rem 0.8rem;
    gap: 0.4rem;
}

/* Customer info with copy button on right */
.order-info-compact {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.order-info-left {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    min-width: 0;
}

.order-info-compact .order-info-row {
    padding: 0.1rem 0;
}

.btn-copy-compact {
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid var(--border);
    padding: 0.4rem;
    border-radius: 6px;
    color: var(--secondary);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-copy-compact:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Expandable info row */
.order-info-expandable {
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 4px;
    margin: 0 -0.25rem;
    padding: 0.2rem 0.25rem !important;
}

.order-info-expandable:hover {
    background: rgba(0,0,0,0.03);
}

.order-value-truncate {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-info-expandable.expanded .order-value-truncate {
    -webkit-line-clamp: unset;
}

/* Products inline preview */
.order-products-inline {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 4px;
    margin: 0 -0.25rem;
    padding: 0.2rem 0.25rem;
}

.order-products-inline:hover {
    background: rgba(0,0,0,0.03);
}

.order-products-preview {
    flex: 1;
    font-size: 0.8rem;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-products-more {
    font-size: 0.6rem;
    color: #999;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.order-products-inline:hover .order-products-more {
    color: var(--primary);
}

/* Pricing in single row */
.order-pricing-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    padding: 0.35rem 0;
    border-top: 1px solid var(--border);
    margin-top: 0.2rem;
}

.order-price-label {
    color: var(--secondary);
}

.order-price-divider {
    color: #ccc;
}

.order-price-delivery {
    color: var(--secondary);
    font-size: 0.75rem;
}

.order-price-total {
    font-weight: 600;
    color: var(--primary);
    margin-left: auto;
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

/* Extra info row */
.order-extra-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-top: 0.3rem;
    border-top: 1px solid var(--border);
}

.order-extra-item {
    font-size: 0.7rem;
    color: var(--secondary);
    background: rgba(0,0,0,0.03);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-notes-preview {
    cursor: pointer;
    max-width: 150px;
}

.order-notes-preview.expanded {
    max-width: none;
    white-space: normal;
}

/* Compact footer */
.order-card .order-card-footer {
    padding: 0.5rem 0.8rem;
}

.order-card .order-actions {
    width: 100%;
    justify-content: flex-end;
}

.order-card .btn-icon-only {
    width: 32px;
    height: 32px;
    padding: 0.35rem !important;
}

/* Smaller avatar */
.order-card .order-avatar {
    width: 36px;
    height: 36px;
    font-size: 16px;
}

/* Adjust header padding */
.order-card .order-card-header {
    padding: 0.5rem 0.8rem;
}

.order-card .order-user-info {
    padding-left: 0;
    gap: 0.6rem;
}

/* ========================================
   RESPONSIVE TABLE & MODALS
   ======================================== */

/* Hide elements on mobile */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .order-table-actions {
        flex-wrap: nowrap;
        gap: 0.15rem;
    }

    .btn-icon-sm {
        padding: 0.25rem;
        width: 28px;
        height: 28px;
    }

    .order-table-cell {
        padding: 0.4rem 0.25rem;
    }

    .orders-table {
        font-size: 0.8rem;
    }

    .order-table-name {
        font-weight: 500;
        font-size: 0.75rem;
        max-width: 80px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .order-table-customer {
        max-width: 90px;
    }

    .order-table-meta {
        font-size: 0.7rem;
    }

    .order-price-display {
        font-size: 0.8rem;
    }

    .currency-small {
        font-size: 0.65rem;
    }
}

/* Button icon info style */
.btn-icon-info {
    color: var(--primary) !important;
}

.btn-icon-info:hover {
    background: var(--primary) !important;
    color: white !important;
}

/* ========================================
   FULLSCREEN DIALOG MODAL
   ======================================== */

.modal-fullscreen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.dialog-modal-container {
    width: 100%;
    max-width: 800px;
    height: 100%;
    max-height: 100vh;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    border-radius: 0;
}

@media (min-width: 769px) {
    .dialog-modal-container {
        height: 90vh;
        max-height: 90vh;
        border-radius: 12px;
        margin: 5vh auto;
    }
}

.dialog-modal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: white;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.dialog-modal-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--secondary);
    border-radius: 50%;
    transition: all 0.2s;
}

.dialog-modal-close:hover {
    background: var(--light);
    color: var(--dark);
}

.dialog-modal-title {
    flex: 1;
    font-weight: 600;
    font-size: 1rem;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dialog-modal-actions {
    display: flex;
    gap: 0.5rem;
}

.dialog-modal-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dialog-modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.dialog-modal-input {
    padding: 0.75rem 1rem;
    background: white;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.dialog-modal-input-group {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.dialog-modal-input-group textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    max-height: 120px;
    overflow-y: auto;
}

.dialog-modal-input-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.dialog-modal-input-group .btn-primary {
    padding: 0.6rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.dialog-modal-input-group .btn-ai-suggest {
    padding: 0.5rem;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.dialog-modal-input-group .btn-ai-suggest:hover {
    background: var(--light);
    border-color: var(--primary);
}

.btn-ai-suggest-deepseek {
    color: #00b894;
}

.btn-ai-suggest-claude {
    color: #d35400;
}

/* ========================================
   SUMMARY MODAL
   ======================================== */

.modal-content-lg {
    max-width: 600px;
    width: 90%;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary);
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--dark);
}

.summary-loading,
.summary-error {
    padding: 2rem;
    text-align: center;
    color: var(--secondary);
}

.summary-result {
    padding: 1.25rem;
}

.summary-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--dark);
}

.summary-modal-actions {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--light);
}

.ai-model-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-ai-model {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-ai-model:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Loading spinner animation */
.spinner-icon {
    animation: rotate 2s linear infinite;
    width: 40px;
    height: 40px;
}

.spinner-path {
    stroke: var(--primary);
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.loading-spinner p {
    color: var(--secondary);
    font-size: 0.9rem;
}

/* ========================================
   EXPANDABLE ORDER TABLE ROWS
   ======================================== */
.order-table-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.order-table-row:hover {
    background-color: #f8f9fa !important;
}

/* Info cell with collapsible rows */
.order-info-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.order-table-row:not(.expanded) .order-info-content {
    gap: 0.15rem;
}

.order-info-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.order-number-tiny {
    font-size: 0.7rem;
    color: #999;
}

.order-vk-name {
    font-weight: 500;
    color: #000;
}

/* Hide expandable content by default */
.order-table-row:not(.expanded) .order-info-expandable {
    display: none;
}

/* Products cell */
.order-products-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.order-product-item {
    font-size: 0.9rem;
}

/* Show short text by default, full text when expanded */
.order-table-row:not(.expanded) .product-full {
    display: none;
}

.order-table-row.expanded .product-short {
    display: none;
}

.order-table-row:not(.expanded) .product-full {
    display: none;
}

.order-table-row.expanded .product-full {
    display: block;
}

/* Date and status cell */
.date-status-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.order-date-info {
    display: flex;
    flex-direction: column;
}

/* Actions cell */
.order-actions-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.order-actions-main {
    display: flex;
    gap: 0.25rem;
}

.order-actions-extra {
    display: none;
    gap: 0.25rem;
}

.order-table-row.expanded .order-actions-extra {
    display: flex;
}

/* Prevent row click on action buttons */
.order-actions-cell {
    pointer-events: all;
}

.order-actions-cell * {
    pointer-events: auto;
}
