:root {
    --primary-color: #2563eb;
    --bg-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #EA4335;
    
    --courier-1: #e74c3c;
    --courier-2: #8e44ad;
    --courier-3: #2980b9;
    --unassigned: #95a5a6;

    /* Corporate design variables */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #f59e0b;
    --telegram: #0088cc;
    --email: #EA4335;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.3s ease;
}

/* Branded Layout */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.studia-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 2px 0 10px rgba(0,0,0,0.02);
}

.main-content {
    flex-grow: 1;
    height: 100vh;
    overflow: hidden;
    position: relative;
    background: var(--background);
}

/* Nav Link Hover & Active */
.nav-link {
    background: transparent;
    color: var(--text) !important;
}
.nav-link:hover {
    background: rgba(37, 99, 235, 0.05);
    color: var(--primary) !important;
}
.nav-link.active {
    background: var(--primary);
    color: #ffffff !important;
}

/* Marketing Link Hover */
.marketing-item {
    background: #ffffff;
    border: 1px solid var(--border);
}
.marketing-item:hover {
    background: var(--background);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Support Icons hover */
.support-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #ffffff;
    text-decoration: none;
}
.support-icon:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.support-icon.telegram:hover {
    background: rgba(0, 136, 204, 0.1);
}
.support-icon.email:hover {
    background: rgba(234, 67, 53, 0.1);
}

/* Обязательный стиль для иконки Макса (без обводки) */
.support-icon.max-icon {
    border: none !important;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    width: auto;
}
.support-icon.max-icon img {
    width: 45px;
    height: 45px;
    object-fit: contain;
    transition: var(--transition);
}
.support-icon.max-icon:hover {
    transform: translateY(-3px);
}
.support-icon.max-icon:hover img {
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.15));
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.dashboard-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Сайдбар */
.sidebar {
    width: 380px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    z-index: 10;
}

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

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

.header-top h2 {
    font-size: 1.2rem;
    color: var(--text-main);
    margin: 0;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.icon-btn:hover {
    opacity: 1;
}

.date-picker-wrapper {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.date-picker-wrapper label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.date-picker-wrapper input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    outline: none;
}

/* Курьеры */
.couriers-section {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.couriers-section h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--text-main);
}

.couriers-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 250px; /* Примерно на 5 курьеров */
    overflow-y: auto;
    padding-right: 5px;
}

/* Стилизация скроллбара для красивого отображения */
.couriers-list::-webkit-scrollbar {
    width: 6px;
}
.couriers-list::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

.courier-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.courier-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    align-items: center;
}

.courier-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.courier-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Заказы */
.orders-section {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.orders-section h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--text-main);
}

.orders-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.order-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: box-shadow 0.2s;
    border-left: 4px solid var(--unassigned);
}

.order-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.order-header {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    font-size: 0.95rem;
}

.order-time {
    color: var(--primary-color);
}

.order-address {
    font-size: 0.85rem;
    color: var(--text-main);
    line-height: 1.4;
}

.order-coord-status {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.order-comment {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 2px;
    background-color: rgba(243, 156, 18, 0.1);
    padding: 4px 6px;
    border-radius: 4px;
    border-left: 2px solid var(--warning-color);
}

.status-ok { color: var(--success-color); }
.status-wait { color: var(--warning-color); }

.order-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.courier-select {
    padding: 6px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    outline: none;
    width: 100%;
}

/* Карта */
.map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* Кастомный попап на карте */
.custom-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.custom-popup .popup-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.custom-popup h4 {
    margin: 0;
    color: var(--text-main);
}

.custom-popup p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.popup-comment {
    background-color: rgba(243, 156, 18, 0.1);
    padding: 6px;
    border-radius: 4px;
    font-style: italic;
    border-left: 2px solid var(--warning-color);
}

/* --- Модальное окно --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: var(--sidebar-bg);
    width: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.modal-overlay.hidden .modal-content {
    transform: translateY(-20px);
}

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

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

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-group input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary-color);
}

.hintText {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.primary-btn:hover {
    background-color: #3a7bc8;
}

.success-btn {
    background-color: var(--success-color);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: bold;
    transition: background-color 0.2s;
}

.success-btn:hover {
    background-color: #219653;
}

.multi-select { width: 100%; min-height: 100px; padding: 8px; border: 1px solid #ddd; border-radius: 4px; background: white; font-size: 14px; } .multi-select option { padding: 4px 8px; margin-bottom: 2px; border-radius: 3px; } .multi-select option:checked { background: var(--primary-color) linear-gradient(0deg, var(--primary-color) 0%, var(--primary-color) 100%); color: white; }

.header-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 15px; } .full-width { width: 100%; justify-content: center; } .secondary-btn { background: #95a5a6; color: white; border: none; padding: 10px 15px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all 0.3s ease; } .secondary-btn:hover { background: #7f8c8d; transform: translateY(-2px); }

.order-warehouse { font-size: 0.82em; color: #c0392b; font-weight: 600; margin-top: 4px; display: flex; align-items: center; gap: 4px; background: rgba(230, 126, 34, 0.1); padding: 3px 7px; border-radius: 4px; border-left: 3px solid #e67e22; }

/* Ссылка на заказ в CRM */
.order-link {
    color: var(--text-main);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s ease, border-bottom 0.2s ease;
    border-bottom: 1px dotted transparent;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.order-link:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.address-link {
    color: inherit;
    text-decoration: underline;
}

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

.order-custom-fields {
    font-size: 0.8rem;
    color: #444;
    background: #f8f9fa;
    padding: 6px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    margin-top: 4px;
}

.custom-field-item {
    margin-bottom: 2px;
}

.custom-field-item:last-child {
    margin-bottom: 0;
}

/* --- Табы в настройках --- */
.settings-modal-wide {
    width: 600px;
    max-width: 95vw;
}

.settings-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: #f8f9fa;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 12px 15px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: rgba(74, 144, 226, 0.05);
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* --- Списки чекбоксов --- */
.checkbox-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    background: white;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.1s;
}

.checkbox-item:hover {
    background: #f0f4f8;
}

.checkbox-item input[type="checkbox"] {
    margin-top: 3px;
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

.checkbox-item span {
    font-size: 0.9rem;
    color: var(--text-main);
    user-select: none;
}

.checkbox-loading {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
    padding: 5px;
}

/* Time Slots Filter CSS */
.time-slot-chip {
    padding: 6px 12px;
    background-color: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    font-weight: 500;
}
.time-slot-chip:hover {
    background-color: #e2e8f0;
    transform: translateY(-1px);
}
.time-slot-chip.selected {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

