/* ============================================
   Innotech CRM - Common Styles
   Все кнопки и общие стили CRM
   ============================================ */

:root {
    /* Primary color - синий как в Clear Sales */
    --crm-primary: #2c3e6e;
    --crm-primary-hover: #3a4f7a;
    --crm-primary-light: #e8edf5;

    /* Secondary colors */
    --crm-success: #22c55e;
    --crm-danger: #c62828;
    --crm-warning: #f57c00;
    --crm-info: #1976d2;

    /* Neutral colors */
    --crm-text: #333;
    --crm-text-muted: #666;
    --crm-text-light: #888;
    --crm-border: #e0e0e0;
    --crm-border-light: #f0f0f0;
    --crm-bg: #fff;
    --crm-bg-light: #fafafa;
    --crm-bg-hover: #f5f5f5;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    padding: 8px 16px;
    border: 1px solid var(--crm-border);
    border-radius: 6px;
    background: var(--crm-bg);
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--crm-text);
    transition: all 0.15s ease;
    font-family: inherit;
}

.btn:hover {
    background: var(--crm-bg-hover);
    border-color: #ccc;
}

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

/* Primary button - main action */
.btn-primary {
    background: var(--crm-primary);
    color: #fff;
    border-color: var(--crm-primary);
}

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

/* Secondary button - secondary action */
.btn-secondary {
    background: var(--crm-bg);
    color: var(--crm-primary);
    border-color: var(--crm-primary);
}

.btn-secondary:hover {
    background: var(--crm-primary-light);
}

/* Success button */
.btn-success {
    background: var(--crm-success);
    color: #fff;
    border-color: var(--crm-success);
}

.btn-success:hover {
    background: #1ea34e;
    border-color: #1ea34e;
}

/* Danger button */
.btn-danger {
    background: var(--crm-danger);
    color: #fff;
    border-color: var(--crm-danger);
}

.btn-danger:hover {
    background: #b71c1c;
    border-color: #b71c1c;
}

/* Small button */
.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Large button */
.btn-lg {
    padding: 12px 24px;
    font-size: 14px;
}

/* ============================================
   Form inputs
   ============================================ */

.form-control {
    padding: 8px 12px;
    border: 1px solid var(--crm-border);
    font-size: 14px;
    color: var(--crm-text);
    background: var(--crm-bg);
    transition: border-color 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--crm-primary);
}

/* ============================================
   Tabs
   ============================================ */

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

/* ============================================
   Links
   ============================================ */

a.link-primary {
    color: var(--crm-primary);
}

a.link-primary:hover {
    color: var(--crm-primary-hover);
}

/* ============================================
   Badges
   ============================================ */

.badge-primary {
    background: var(--crm-primary-light);
    color: var(--crm-primary);
}

/* ============================================
   Navigation active state
   ============================================ */

.nav-links a.active {
    color: var(--crm-text);
    border-bottom-color: var(--crm-primary);
}

/* ============================================
   CRM Layout - Общая структура страниц
   ============================================ */

.crm-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 40px;
}

.crm-main-content {
    padding: 15px 0;
}

.crm-page-header {
    margin-bottom: 15px;
}

.crm-page-header h1 {
    font-size: 22px;
    font-weight: 400;
    color: #333;
}

/* Breadcrumbs */
.crm-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 13px;
    margin-bottom: 10px;
}

.crm-breadcrumbs a {
    color: #666;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.crm-breadcrumbs a:hover {
    color: #1a73e8;
}

.crm-breadcrumbs a svg {
    width: 16px;
    height: 16px;
}

.crm-breadcrumbs .separator {
    color: #ccc;
    font-size: 11px;
}

.crm-breadcrumbs .current {
    color: #333;
    font-weight: 500;
}

/* Cards */
.crm-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    padding: 15px;
}

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

.crm-card-title {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.crm-card-link {
    font-size: 12px;
    color: #888;
    text-decoration: none;
}

.crm-card-link:hover {
    color: #333;
}

/* Balance items */
.crm-balance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f5f5f5;
}

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

.crm-balance-currency {
    font-size: 13px;
    color: #333;
}

.crm-balance-amount {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

/* Quick actions */
.crm-quick-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.crm-quick-btn {
    padding: 8px 14px;
    font-size: 13px;
    border: 1px solid #e0e0e0;
    background: #fff;
    color: #333;
    text-decoration: none;
    cursor: pointer;
}

.crm-quick-btn:hover {
    background: #f5f5f5;
}

.crm-quick-btn.purchase {
    background: #047857;
    color: #fff;
    border-color: #047857;
}

.crm-quick-btn.purchase:hover {
    background: #065f46;
    border-color: #065f46;
}

.crm-quick-btn.sale {
    background: #881337;
    color: #fff;
    border-color: #881337;
}

.crm-quick-btn.sale:hover {
    background: #6b1029;
    border-color: #6b1029;
}

/* Section headers */
.crm-section-label {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 4px;
}

/* Grid */
.crm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* Tables */
.crm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.crm-table th,
.crm-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.crm-table th {
    font-weight: 500;
    color: #666;
    background: #fafafa;
}

.crm-table tr:hover {
    background: #f9f9f9;
}

/* Filters */
.crm-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.crm-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.crm-filter-group label {
    font-size: 13px;
    color: #666;
}

.crm-filter-group select,
.crm-filter-group input {
    padding: 6px 10px;
    border: 1px solid #ddd;
    font-size: 13px;
    min-width: 140px;
}

/* Status badges */
.crm-status {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 3px;
}

.crm-status-draft {
    background: #f5f5f5;
    color: #666;
}

.crm-status-confirmed {
    background: #e3f2fd;
    color: #1976d2;
}

.crm-status-paid {
    background: #fff3e0;
    color: #f57c00;
}

.crm-status-completed {
    background: #e8f5e9;
    color: #388e3c;
}

/* Modals */
.crm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.crm-modal.show {
    display: flex;
}

.crm-modal-content {
    background: #fff;
    padding: 25px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.crm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.crm-modal-header h2 {
    font-size: 18px;
    font-weight: 500;
}

.crm-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #888;
}

/* Form groups */
.crm-form-group {
    margin-bottom: 15px;
}

.crm-form-group label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 5px;
}

.crm-form-group input,
.crm-form-group select,
.crm-form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.crm-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.crm-form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Empty state */
.crm-empty {
    text-align: center;
    padding: 40px 20px;
    color: #888;
}

/* Actions column */
.crm-actions {
    display: flex;
    gap: 8px;
}

.crm-actions a,
.crm-actions button {
    color: #666;
    text-decoration: none;
    font-size: 12px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.crm-actions a:hover,
.crm-actions button:hover {
    color: #333;
}

/* Responsive */
@media (max-width: 768px) {
    .crm-container {
        padding: 0 15px;
    }

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

    .crm-form-row {
        grid-template-columns: 1fr;
    }

    .crm-table {
        display: block;
        overflow-x: auto;
    }

    .crm-filters {
        flex-direction: column;
    }
}

/* ============================================
   TOP NAVIGATION - Единый стиль для всех страниц
   ============================================ */

/* Top nav bar - логотип и пользователь */
.top-nav {
    padding: 15px 0 !important;
    margin-bottom: 0 !important;
}

.top-nav-inner {
    max-width: 1600px !important;
    margin: 0 auto !important;
    padding: 0 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
}

.logo {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    text-decoration: none !important;
    color: #333 !important;
    font-size: 16px !important;
    font-weight: 500 !important;
}

.logo:hover { color: #000 !important; }
.logo svg { flex-shrink: 0 !important; }

/* CRM Submenu - меню второго уровня */
.crm-nav {
    background: #fafafa !important;
    margin-bottom: 0 !important;
}

.crm-nav-inner {
    max-width: 1600px !important;
    margin: 0 auto !important;
    padding: 0 40px !important;
    display: flex !important;
    gap: 0 !important;
}

.crm-nav-item {
    position: relative !important;
    cursor: pointer !important;
}

.crm-nav-label {
    display: block !important;
    padding: 14px 20px !important;
    color: #555 !important;
    font-size: 14px !important;
    user-select: none !important;
}

.crm-nav-item:hover .crm-nav-label {
    color: #333;
    background: #f0f0f0;
}

.crm-nav-item .dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 220px;
    z-index: 1000;
    border: 1px solid #e0e0e0;
    border-top: none;
}

.crm-nav-item:hover .dropdown { display: block; }

.dropdown a {
    display: block;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown a:last-child { border-bottom: none; }
.dropdown a:hover { background: #f5f5f5; }
.dropdown a .sub { font-size: 11px; color: #888; display: block; margin-top: 2px; }

/* User menu */
.user-menu { position: relative; }
.user-menu-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #e0e0e0;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.user-menu-btn:hover { background: #f5f5f5; }
.user-menu-btn svg { width: 20px; height: 20px; color: #666; }

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 220px;
    z-index: 1000;
}
.user-dropdown.show { display: block; }

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.user-dropdown-item:hover { background: #f5f5f5; }
.user-dropdown-item svg { width: 18px; height: 18px; color: #666; }

.user-dropdown-divider { height: 1px; background: #e0e0e0; margin: 4px 0; }

.user-dropdown-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
}
.user-dropdown-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e8f4f8;
    display: flex;
    align-items: center;
    justify-content: center;
}
.user-dropdown-avatar svg { width: 24px; height: 24px; color: #666; }
.user-dropdown-name { font-size: 14px; font-weight: 500; color: #333; }
.user-dropdown-role { font-size: 12px; color: #1a73e8; text-transform: uppercase; }

/* ============================================
   Legacy class overrides - для совместимости
   со старыми страницами
   ============================================ */

/* Container */
.container {
    max-width: 1600px !important;
    margin: 0 auto !important;
    padding: 0 40px !important;
}

/* Убираем все линии после breadcrumbs */
.breadcrumbs {
    border-bottom: none !important;
    border-top: none !important;
}

.container > .breadcrumbs + header,
.container > .breadcrumbs + * {
    border-top: none !important;
}

/* Main content - компактный */
.main-content {
    padding: 0 !important;
}

/* Page header - компактный */
.page-header {
    margin-bottom: 15px !important;
}

.page-header h1 {
    font-size: 22px !important;
    font-weight: 400 !important;
    color: #333 !important;
}

/* Breadcrumbs - компактный */
.breadcrumbs {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 0 !important;
    font-size: 13px !important;
    margin-bottom: 10px !important;
}

.breadcrumbs a {
    color: #666;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.breadcrumbs a:hover {
    color: #1a73e8;
}

.breadcrumbs a svg {
    width: 16px;
    height: 16px;
}

.breadcrumbs .separator {
    color: #ccc;
    font-size: 11px;
}

.breadcrumbs .current {
    color: #333;
    font-weight: 500;
}

/* Header с кнопкой */
header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 15px !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
}

header h1 {
    font-size: 22px !important;
    font-weight: 400 !important;
    color: #333 !important;
}

/* Tables - компактный */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead tr {
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
}

tbody tr {
    border-bottom: 1px solid #e0e0e0;
}

th, td {
    padding: 10px 12px;
    text-align: left;
}

th {
    font-weight: 500;
    color: #666;
    background: #fafafa;
}

tr:hover {
    background: #f9f9f9;
}

/* Table wrapper */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
}

/* Filters - компактный */
.filters {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 13px;
    color: #666;
}

.filter-group select,
.filter-group input {
    padding: 6px 10px;
    border: 1px solid #ddd;
    font-size: 13px;
    min-width: 140px;
}

/* Modal - компактный */
.modal-content {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 500;
}

/* Form - компактный */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 3px;
}

.status-draft {
    background: #f5f5f5;
    color: #666;
}

.status-confirmed {
    background: #e3f2fd;
    color: #1976d2;
}

.status-paid {
    background: #fff3e0;
    color: #f57c00;
}

.status-completed {
    background: #e8f5e9;
    color: #388e3c;
}

/* Actions */
.actions {
    display: flex;
    gap: 8px;
}

.actions a,
.actions button {
    color: #666;
    text-decoration: none;
    font-size: 12px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.actions a:hover,
.actions button:hover {
    color: #333;
}

/* Total count */
.total-count {
    color: #888;
    font-size: 13px;
    margin-bottom: 10px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #888;
}

/* Responsive for legacy */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    table {
        display: block;
        overflow-x: auto;
    }

    .filters {
        flex-direction: column;
    }
}

/* ============================================
   Footer - Sticky to bottom
   ============================================ */

html, body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.crm-page-wrapper {
    flex: 1 0 auto;
}

.crm-footer {
    flex-shrink: 0;
    background: #000;
    padding: 20px 0;
    margin-top: 40px;
}

.crm-footer-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 40px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.crm-footer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

.crm-footer-logo svg {
    flex-shrink: 0;
}

/* ============================================
   Custom Select Dropdown
   Единый стиль для всех выпадающих списков
   ============================================ */

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: border-color 0.2s, box-shadow 0.2s;
    height: 42px;
    box-sizing: border-box;
}

.custom-select-trigger:hover {
    border-color: #bbb;
}

.custom-select.open .custom-select-trigger {
    border-color: var(--crm-info, #1976d2);
    box-shadow: 0 0 0 3px rgba(25,118,210,0.1);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.custom-select-trigger .placeholder {
    color: #999;
}

.custom-select-trigger .selected-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-trigger .icons {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
}

.custom-select-trigger .icon-clear {
    color: #999;
    cursor: pointer;
    padding: 2px;
    border-radius: 50%;
    display: none;
    font-size: 12px;
}

.custom-select-trigger .icon-clear:hover {
    color: #666;
    background: #f0f0f0;
}

.custom-select.has-value .icon-clear {
    display: block;
}

.custom-select-trigger .icon-arrow {
    color: #666;
    transition: transform 0.2s;
    font-size: 10px;
}

.custom-select.open .icon-arrow {
    transform: rotate(180deg);
}

.custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--crm-info, #1976d2);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

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

.custom-select-option {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.15s;
}

.custom-select-option:hover {
    background: #f5f7fa;
}

.custom-select-option.selected {
    background: #e3f2fd;
    color: var(--crm-info, #1976d2);
}

.custom-select-option:first-child {
    border-top: none;
}

.custom-select-search {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: #fff;
}

.custom-select-search input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    min-height: auto !important;
    height: auto !important;
}

.custom-select-search input:focus {
    border-color: var(--crm-info, #1976d2);
}

.custom-select-empty {
    padding: 16px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* Disabled state */
.custom-select.disabled .custom-select-trigger {
    background: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Small variant */
.custom-select.custom-select-sm .custom-select-trigger {
    height: 36px;
    font-size: 13px;
    padding: 0 10px;
}

.custom-select.custom-select-sm .custom-select-option {
    padding: 10px 14px;
    font-size: 13px;
}

/* ============================================
   Date Range Picker
   ============================================ */

.date-range-picker {
    position: relative;
    display: inline-block;
    font-family: inherit;
}

.date-picker-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: #fff;
    border: 1px solid var(--crm-border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    min-width: 210px;
    height: 32px;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.date-picker-trigger:hover {
    border-color: #999;
}

.date-picker-icons {
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-picker-clear {
    font-size: 11px;
    color: #999;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    transition: color 0.15s;
}

.date-picker-clear:hover {
    color: var(--crm-danger);
}

.date-picker-text {
    flex: 1;
    color: var(--crm-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.date-picker-arrow {
    font-size: 10px;
    color: var(--crm-text-muted);
    transition: transform 0.2s;
}

.date-picker-dropdown.open + .date-picker-trigger .date-picker-arrow,
.date-range-picker:has(.date-picker-dropdown.open) .date-picker-arrow {
    transform: rotate(180deg);
}

.date-picker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid var(--crm-border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: none;
    margin-top: 4px;
}

.date-picker-dropdown.open {
    display: block;
}

.date-picker-content {
    display: flex;
}

.date-picker-calendars {
    display: flex;
    gap: 0;
    border-right: 1px solid var(--crm-border-light);
}

.date-picker-calendar {
    padding: 16px;
    min-width: 260px;
}

.date-picker-calendar:first-child {
    border-right: 1px solid var(--crm-border-light);
}

.date-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.date-picker-month-year {
    font-weight: 600;
    font-size: 14px;
    color: var(--crm-text);
}

.date-picker-nav {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    color: var(--crm-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.date-picker-nav:hover {
    color: var(--crm-primary);
}

.date-picker-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    margin-bottom: 8px;
}

.date-picker-weekdays span {
    text-align: center;
    font-size: 12px;
    color: var(--crm-text-muted);
    padding: 4px 0;
    text-transform: lowercase;
}

.date-picker-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.date-picker-day {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 0;
    transition: all 0.15s;
    color: var(--crm-text);
}

.date-picker-day:hover:not(.other-month) {
    background: var(--crm-primary-light);
}

.date-picker-day.other-month {
    color: #ccc;
    cursor: default;
}

.date-picker-day.today {
    font-weight: 600;
    color: var(--crm-primary);
}

.date-picker-day.weekend:not(.other-month) {
    color: var(--crm-danger);
}

.date-picker-day.start-date,
.date-picker-day.end-date {
    background: var(--crm-primary);
    color: #fff !important;
}

.date-picker-day.start-date {
    border-radius: 4px 0 0 4px;
}

.date-picker-day.end-date {
    border-radius: 0 4px 4px 0;
}

.date-picker-day.start-date.end-date {
    border-radius: 4px;
}

.date-picker-day.in-range {
    background: var(--crm-primary-light);
}

/* Sidebar with month buttons */
.date-picker-sidebar {
    padding: 16px;
    min-width: 110px;
    background: var(--crm-bg-light);
}

.date-picker-months {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.date-picker-month-btn {
    padding: 8px 12px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    color: var(--crm-primary);
    transition: all 0.15s;
    font-family: inherit;
}

.date-picker-month-btn:hover {
    background: var(--crm-primary-light);
}

.date-picker-month-btn.active {
    background: var(--crm-primary);
    color: #fff;
    border-color: var(--crm-primary);
}

/* Footer with buttons */
.date-picker-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--crm-border-light);
    background: var(--crm-bg-light);
}

.date-picker-btn {
    padding: 8px 20px;
    border: 1px solid var(--crm-border);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.15s;
}

.date-picker-btn-reset {
    background: #fff;
    color: var(--crm-text);
}

.date-picker-btn-reset:hover {
    background: var(--crm-bg-hover);
}

.date-picker-btn-apply {
    background: var(--crm-primary);
    color: #fff;
    border-color: var(--crm-primary);
}

.date-picker-btn-apply:hover {
    background: var(--crm-primary-hover);
}

/* Compact variant for filters */
.date-range-picker.compact .date-picker-trigger {
    min-width: 220px;
    height: 32px;
    font-size: 13px;
}

/* ============================================
   Global border-radius for all elements
   ============================================ */

/* All inputs, selects, textareas */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
    border-radius: 6px;
}

/* Cards and panels */
.card,
.panel,
.block,
.widget,
.info-block,
.summary-block {
    border-radius: 8px;
}

/* Tables */
table {
    border-radius: 8px;
    overflow: hidden;
}

/* Status badges */
.status-badge,
.badge {
    border-radius: 4px;
}

/* Dropdowns */
.dropdown-menu,
.actions-dropdown-menu,
.custom-select-dropdown {
    border-radius: 6px;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   Полная мобильная адаптация CRM
   ============================================ */

/* Mobile menu button - скрыт на десктопе */
.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background: var(--crm-bg-hover);
}

.mobile-menu-btn svg {
    width: 20px;
    height: 20px;
    color: var(--crm-text);
}

/* Mobile menu overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.show {
    display: block;
    opacity: 1;
}

/* Mobile menu drawer */
.mobile-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100%;
    background: #fff;
    z-index: 9999;
    transition: left 0.3s ease;
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.mobile-menu.show {
    left: 0;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--crm-border);
    background: var(--crm-bg-light);
}

.mobile-menu-header span {
    font-size: 16px;
    font-weight: 500;
    color: var(--crm-text);
}

.mobile-menu-close {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.mobile-menu-close:hover {
    background: var(--crm-bg-hover);
}

.mobile-menu-close svg {
    width: 20px;
    height: 20px;
    color: var(--crm-text-muted);
}

.mobile-menu-content {
    padding: 12px 0;
}

.mobile-menu-section {
    padding: 8px 0;
    border-bottom: 1px solid var(--crm-border-light);
}

.mobile-menu-section:last-child {
    border-bottom: none;
}

.mobile-menu-section-title {
    padding: 8px 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--crm-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-menu-item {
    display: block;
    padding: 12px 20px;
    color: var(--crm-text);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s;
}

.mobile-menu-item:hover,
.mobile-menu-item:active {
    background: var(--crm-bg-hover);
}

.mobile-menu-item.active {
    background: var(--crm-primary-light);
    color: var(--crm-primary);
    font-weight: 500;
}

.mobile-menu-item .sub {
    display: block;
    font-size: 11px;
    color: var(--crm-text-muted);
    margin-top: 2px;
}

/* Top nav actions container */
.top-nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ============================================
   TABLET BREAKPOINT (768px)
   ============================================ */

@media (max-width: 768px) {
    /* Container padding */
    .crm-container,
    .container,
    .top-nav-inner,
    .crm-nav-inner,
    .crm-footer-inner {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    /* Grid layouts */
    .crm-grid {
        grid-template-columns: 1fr;
    }

    /* Forms - single column */
    .crm-form-row,
    .form-row {
        grid-template-columns: 1fr;
    }

    /* Tables - horizontal scroll */
    .crm-table,
    table,
    .table-wrapper {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Filters */
    .crm-filters,
    .filters {
        flex-direction: column;
        gap: 10px;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group select,
    .filter-group input {
        flex: 1;
        min-width: 0;
    }

    /* Modal */
    .crm-modal-content,
    .modal-content {
        max-width: 95%;
        margin: 20px;
    }

    /* Page header */
    header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Quick actions */
    .crm-quick-actions {
        flex-wrap: wrap;
    }

    .crm-quick-btn {
        flex: 1 1 calc(50% - 5px);
        min-width: 120px;
        text-align: center;
        justify-content: center;
    }

    /* Date picker - stack calendars */
    .date-picker-content {
        flex-direction: column;
    }

    .date-picker-calendars {
        flex-direction: column;
        border-right: none;
        border-bottom: 1px solid var(--crm-border-light);
    }

    .date-picker-calendar:first-child {
        border-right: none;
        border-bottom: 1px solid var(--crm-border-light);
    }

    .date-picker-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        min-width: auto;
        padding: 12px;
    }

    .date-picker-months {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .date-picker-month-btn {
        padding: 6px 12px;
    }
}

/* ============================================
   MOBILE BREAKPOINT (576px)
   ============================================ */

@media (max-width: 576px) {
    /* Container padding */
    .crm-container,
    .container,
    .top-nav-inner,
    .crm-footer-inner {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* Hide desktop navigation, show hamburger */
    .crm-nav {
        display: none !important;
    }

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

    /* Logo text - hide on very small screens */
    .logo span {
        display: none;
    }

    /* Page title */
    .crm-page-header h1,
    .page-header h1,
    header h1 {
        font-size: 18px !important;
    }

    /* Forms - touch-friendly */
    .crm-form-group input,
    .crm-form-group select,
    .crm-form-group textarea,
    .form-group input,
    .form-group select,
    .form-group textarea,
    .filter-group input,
    .filter-group select {
        height: 44px;
        font-size: 16px; /* Prevents iOS zoom */
        padding: 10px 12px;
    }

    textarea {
        min-height: 80px;
    }

    /* Buttons - touch-friendly */
    .btn,
    .crm-quick-btn {
        min-height: 44px;
        padding: 10px 16px;
    }

    /* Quick actions - full width */
    .crm-quick-actions {
        gap: 8px;
    }

    .crm-quick-btn {
        flex: 1 1 100%;
    }

    /* Modal - full width */
    .crm-modal-content,
    .modal-content {
        width: 95% !important;
        max-width: none !important;
        max-height: 85vh;
        margin: 10px;
        padding: 15px;
    }

    .modal-header h2,
    .crm-modal-header h2 {
        font-size: 16px;
    }

    /* Form actions - stack vertically */
    .crm-form-actions,
    .form-actions {
        flex-direction: column;
    }

    .crm-form-actions .btn,
    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Table to card transformation - applies to .table-mobile-cards and main tables in .table-wrapper */
    .table-mobile-cards thead,
    .table-wrapper > table thead {
        display: none;
    }

    .table-mobile-cards,
    .table-mobile-cards tbody,
    .table-mobile-cards tr,
    .table-mobile-cards td,
    .table-wrapper > table,
    .table-wrapper > table tbody,
    .table-wrapper > table tr,
    .table-wrapper > table td {
        display: block;
    }

    .table-mobile-cards tr,
    .table-wrapper > table tr {
        background: #fff;
        border: 1px solid var(--crm-border);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 12px;
    }

    .table-mobile-cards tr:hover,
    .table-wrapper > table tr:hover {
        background: #fff;
    }

    .table-mobile-cards td,
    .table-wrapper > table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 8px 0;
        border-bottom: 1px solid var(--crm-border-light);
        text-align: right;
    }

    .table-mobile-cards td:last-child,
    .table-wrapper > table td:last-child {
        border-bottom: none;
    }

    .table-mobile-cards td::before,
    .table-wrapper > table td::before {
        content: attr(data-label);
        font-weight: 500;
        color: var(--crm-text-muted);
        text-align: left;
        flex: 0 0 40%;
        padding-right: 10px;
    }

    /* Actions in card view */
    .table-mobile-cards .actions,
    .table-mobile-cards .crm-actions,
    .table-wrapper > table .actions,
    .table-wrapper > table .crm-actions {
        justify-content: flex-end;
        padding-top: 8px;
        margin-top: 4px;
        border-top: 1px solid var(--crm-border-light);
    }

    .table-mobile-cards td.actions-cell::before,
    .table-wrapper > table td.actions-cell::before {
        display: none;
    }

    /* Hide table-wrapper overflow on mobile since we're using cards */
    .table-wrapper {
        overflow-x: visible;
    }

    /* Custom select - full width */
    .custom-select-trigger {
        height: 44px;
        font-size: 16px;
    }

    .custom-select-dropdown {
        max-height: 50vh;
    }

    .custom-select-option {
        padding: 14px 16px;
    }

    /* Date picker trigger */
    .date-picker-trigger,
    .date-range-picker.compact .date-picker-trigger {
        height: 44px;
        min-width: 100%;
        font-size: 14px;
    }

    /* Date picker dropdown - full width */
    .date-picker-dropdown {
        left: 0 !important;
        right: 0 !important;
        width: auto;
        margin-left: -15px;
        margin-right: -15px;
    }

    .date-picker-calendar {
        min-width: auto;
        padding: 12px;
    }

    .date-picker-day {
        width: 100%;
        height: 36px;
    }

    /* Footer */
    .date-picker-footer {
        flex-direction: column;
        gap: 8px;
    }

    .date-picker-btn {
        width: 100%;
    }

    /* Breadcrumbs - simplified */
    .crm-breadcrumbs,
    .breadcrumbs {
        font-size: 12px;
        flex-wrap: wrap;
    }

    .breadcrumbs a svg {
        width: 14px;
        height: 14px;
    }

    /* Status badges - larger tap targets */
    .crm-status,
    .status-badge {
        padding: 4px 10px;
        font-size: 12px;
    }

    /* Empty state */
    .crm-empty,
    .empty-state {
        padding: 30px 15px;
    }

    /* User dropdown */
    .user-dropdown {
        right: -10px;
        min-width: 200px;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 8px;
    }

    .pagination button,
    .pagination a {
        min-width: 36px;
        min-height: 36px;
    }

    /* Filter group - vertical layout */
    .filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }

    .filter-group label {
        font-size: 12px;
    }
}

/* ============================================
   SMALL PHONE BREAKPOINT (360px)
   ============================================ */

@media (max-width: 360px) {
    /* Even smaller padding */
    .crm-container,
    .container,
    .top-nav-inner,
    .crm-footer-inner {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Smaller title */
    .crm-page-header h1,
    .page-header h1,
    header h1 {
        font-size: 16px !important;
    }

    /* Modal - minimal padding */
    .crm-modal-content,
    .modal-content {
        padding: 12px;
    }

    /* Cards - minimal padding */
    .table-mobile-cards tr {
        padding: 10px;
    }

    /* Font size adjustments */
    .crm-table td,
    table td {
        font-size: 12px;
    }

    /* Buttons - slightly smaller */
    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ============================================
   UTILITY CLASSES FOR MOBILE
   ============================================ */

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

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

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 576px) {
    .show-mobile {
        display: block !important;
    }
}

/* Full width on mobile */
@media (max-width: 576px) {
    .mobile-full-width {
        width: 100% !important;
    }
}

/* Touch-friendly class for links/buttons */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Prevent body scroll when mobile menu is open */
body.mobile-menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}
