:root {
    --primary-color: #4a90e2;
    --bg-color: #f5f7fa;
    --sidebar-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #888888;
    --border-color: #e0e6ed;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    
    --courier-1: #e74c3c;
    --courier-2: #8e44ad;
    --courier-3: #2980b9;
    --unassigned: #95a5a6;
}

* {
    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;
}

.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;
}
